views:

462

answers:

2

The user clicks the URL that is generated via the code below.

$url = 'https://graph.facebook.com/oauth/authorize?' . 
http_build_query(array('client_id'    => FACEBOOK_APP_ID,
                       'redirect_uri'   => 'http://fb.example.com/facebook',
                       'scope'          => 'publish_stream,email,offline_access,user_location,user_hometown',
                       'display'        => 'page'));

Upon granting access to the application, and redirecting to http://fb.example.com/facebook I grab the following URL using cURL.

$url = 'http://graph.facebook.com/oauth/access_token?' . 
http_build_query(array('client_id'      => FACEBOOK_APP_ID,
                       'client_secret'  => FACEBOOK_SECRET,
                       'redirect_uri'   => 'http://fb.example.com/facebook',
                       'code'           => $params['code']));

This returns the error below that I receive when grabbing the above URL.

{
   "error": {
      "type": "OAuthException",
      "message": "Error validating verification code."
   }
}

Any ideas? Really getting stuck on this.

+1  A: 

Is your connect URL (in your application settings on Facebook) fb.example.com? Your redirect_uri needs to be on the same domain as the connect URL on file with Facebook.

ceejayoz
Yes, they are exactly the same.
James
My redirect_uri and connect URL are on the same domain and I am still getting the OAuth exception. This answer is marked as accepted, did putting your code on the same domain as your connect URL fix the problem for you or was it something else?
Richard
+1  A: 

On your second request, try going back to the SSL endpoint (ie. https:/graph.facebook.com) instead of http

Yuliy
shouldn't this be the answer? or at least get recognized
Morten Bergfall