用户被重定向到登录对话框之后
$url = "https://graph.facebook.com/oauth/authorize?client_id=$appid&scope=&" .
"redirect_uri=$process_url";
其中 $process_uri 是表单 https://my.domain.com/process.php?param1=value1¶m2=value2
的 urlen编码网址。用户返回https://my.domain.com/process.php
后,我执行 curl 请求(首先尝试使用file_get_contents
):
$url = "https://graph.facebook.com/oauth/access_token?client_id=" .
"$appid&redirect_uri=$current_url&client_secret=$secret" .
"&code={$_REQUEST['code']}";
我越来越{ "error": { "message": "Error validating verification code.", "type": "OAuthException", "code": 100 } }
.
谷歌搜索后,我意识到可能导致问题的主要原因是 curl 请求中的错误redirect_uri
。问题是:curl 请求中应该redirect_uri
什么? https://my.domain.com/
?还是https://my.domain.com/process.php
?还是https://my.domain.com/process.php?param1=value1¶m2=value2
?
提前谢谢你!
在将当前 URL 作为redirect_uri提交到 https://graph.facebook.com/oauth/access_token 终结点时,请删除代码参数。