7
votes

I am a beginner to Facebook app development. I am stuck with an authentication issue, I am trying to use this url:

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

but I receive this error: "Invalid verification code format."

I have been trying to solve it for the last three hours and no result. I try to google this message but apparently it is not that popular.

can you please help?

Edit: I use this function:

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;
}
}

then I pass the url as a parameter:

$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);

1
might be useful to echo $url before you call echo get_contents($url), to make sure that all the variables are set.Andreas Wong
I did that and also double checked the values and all of them are correctKalimah

1 Answers

12
votes

I think the following link provides the answer: http://developers.facebook.com/docs/authentication/#authenticating-users-in-a-web-application

You first need to call https://graph.facebook.com/oauth/authorize with your client_id and redirect_uri. This will then redirect you back to the redirect_uri, with a verification code in the query string that you can pass to your https://graph.facebook.com/oauth/access_token call (via the code parameter) to exchange for an oAuth access token.

Good luck! :)