Viewed   95 times

very strange error. i use gide so i create request to fb and pass redirect_uri. i use test site on localhost. so if i pass


it works fine, but if i pass


it don't want work. i try to use

redirect_uri= . urlencode('http://localhost/test_blog/index.php?r=site/oauth2)

but not work. i try to explaine. i success get code, but when i access i get error 'Error validating verification code'. i checked evering, error is in ?r=site/oauth2 but i need passing some params can somebody help me? i read post but nothing work for me



There are presently (as of March 2011) undocumented requirements regarding what makes a valid redirect_uri.

First, both redirect_uri paramaters to authorize and access_token must match.

Apparently Facebook (or rather OAuth2) is using the redirect_uri as a internal key to encode the code returned for the access_token request. It's kinda clever since it verifies back to your site. It explains why the access_token request which wouldn't otherwise need a redirect_uri parameter requires one.

Second, you cannot use many special characters in the redirect_uri.

A lot of discussion rages whether parameters can be passed at all. They can, you're limited which characters are valid but no one has published a list that I know. Traditional methods like url/html encoding will fail because percent(%) is not valid. Slash (/) is not valid either so a nested redirection url will always fail. The ONLY way to overcome the special char limitation is to encode the value of the parameter to base64. If you're using ASP.NET, look up Convert.ToBase64.

Lastly, and this is more of a side-note. There are a lot of programmers passing along misinformation that a simple solution is to pass type=client_cred. This may limit your access to some of the permissions you requested in your authorization. It is inadvisable.

Wednesday, November 9, 2022

Using the PHP SDK you can run fql queries by :

$facebook = new Facebook(array(
       'appId'  => 'YOUR_API_KEY',
       'secret' => 'YOUR_API_SECRET',
       'cookie' => true,

 $fql = "Your query";

 $response = $facebook->api(array(
     'method' => 'fql.query',
     'query' =>$fql,


I’ve also seen it done this way as well:

$param  =   array(
      'method'    => 'fql.query',
      'access_token' => $cookie['access_token'],
      'query'     => $fql,
      'callback'  => ''
$response   =   $facebook->api($param);

Hope this helps :)

Saturday, October 29, 2022
3 this link can help you...

Here are some various ways to upload photos using the Graph API. The examples assume you've instantiated the $facebook object and have a valid session.

1 - Default Application Album of Current User This example will upload the photo to your default application album of the current user. If the album does not yet exist it will be created.

$facebook->setFileUploadSupport(true); $args = array('message' => 'Photo Caption'); $args['image'] = '@' . realpath($FILE_PATH);

$data = $facebook->api('/me/photos', 'post', $args); print_r($data); 2 - Target Album` This example will upload the photo to a specific album.

$facebook->setFileUploadSupport(true); $args = array('message' => 'Photo Caption'); $args['image'] = '@' . realpath($FILE_PATH);

$data = $facebook->api('/'. $ALBUM_ID . '/photos', 'post', $args); print_r($data);

Wednesday, September 7, 2022

I recently dealt with exactly this problem: everything matched, but it failed with the OAuthException. The thing that made it work was to change the redirect uri (in both requests for the flow) from:


I.e., add the trailing slash. And then it worked. Stupid and silly, but there you go.

Tuesday, December 20, 2022

There is a modified version of the facebook python SDK which supports OAuth 2.0 and parsing of the fbsr_ cookie on github here:

You can look into the code to see how to parse the cookie or just let that file do the work for you.

Saturday, October 22, 2022
Only authorized users can answer the search term. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :