"验证码格式无效." facebook oauth错误

Kal*_*mah 6 php facebook

我是Facebook应用程序开发的初学者.我遇到了身份验证问题,我正在尝试使用此网址:

https://graph.facebook.com/oauth/access_token?client_id= $ client_id&client_secret = $ client_secret&type = client_credentials&redirect_uri = http://www.wesbite.com/facebook/&scope=email,offline_access

但是我收到此错误:"验证码格式无效."

我一直试图在最后三个小时解决它而没有结果.我尝试谷歌这条消息,但显然它不是那么受欢迎.

你能帮忙吗?

编辑:我使用这个功能:

function get_contents($link)
{
if (function_exists('curl_init')) {
    $curl    = curl_init();
    $timeout = 0;
    curl_setopt($curl, CURLOPT_URL, $link);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, $timeout);
    $buffer = curl_exec($curl);
    curl_close($curl);
    return $buffer;
} elseif (function_exists('file_get_contents')) {
    $buffer = file_get_contents($link);
    return $buffer;
} elseif (function_exists('file')) {
    $buffer = implode('', @file($link));
    return $buffer;
} else {
    return 0;
}
}
Run Code Online (Sandbox Code Playgroud)

然后我将url作为参数传递:

$ url =" https://graph.facebook.com/oauth/access_token?client_id= $ client_id&client_secret = $ client_secret&type = client_credentials&redirect_uri = http://www.mywebsite.com/facebook/&scope=email,offline_access ";

echo get_contents($url);

Rob*_*daz 10

我认为以下链接提供了答案:http://developers.facebook.com/docs/authentication/#authenticating-users-in-a-web-application

首先需要使用client_id和redirect_uri 调用https://graph.facebook.com/oauth/authorize.然后,这将重定向回redirect_uri,查询字符串中的验证码可以传递给您的https://graph.facebook.com/oauth/access_token调用(通过代码参数)以交换oAuth访问权限令牌.

祝好运!:)