0

I am using facebook PHP SDK. After the user allows my application, facebook redirects to may web page. Following is the URL

http://Mydowmain.com/facebook.htm?state=d96afbb9ea550fg81c287b7822cee0af1&code=AQDtl7Rd7qgCp6S_dXwOCxxfXo1dEh75ZJqrCINMawCUzxOYs9JnpmWKMoYTgjuNhQx2nk8pleCdvGqSt39F2pHKMHt3aNxwqoIah2oshPKKC0MnWycPSU0yLAKMYVQV2g3jRQdEMf2dWTVUrk_ammSpGaYbfFQ3GeccZ1vGqfVazsaQ_1Lxz7GjITlqgCxrOlc#_=_

I need to fetch the access_token Following is the code

if($_GET['code'] != '')
        {

$access_token = $facebook->getAccessToken();

When i try to use this $access_token to get the user details.

$user_profile   =   'https://graph.facebook.com/me/?access_token='.$access_token;

It gives the following error

{"error":{"message":"An active access token must be used to query information about the current user.","type":"OAuthException","code":2500}}

}

I dnt what i am doing wrong, it was working with SDK 2 but not working with SDK3

$access_token = $facebook->getAccessToken();

this Call Returns the following, in which fistpart before "|" is App ID and After "|" is App Secret..

187997367916887|9d87d7a2d26485fd926a000b0c3b2f87

Asghar
  • 2,336
  • 8
  • 46
  • 79
  • What access token are you actually getting from the getAccessToken call? Print it out for debugging, and check it with https://developers.facebook.com/tools/debug – CBroe Jun 27 '12 at 16:57
  • $access_token = $facebook->getAccessToken(); this Call Returns the following, in which fistpart before "|" is App ID and After "|" is App Secret.. 187997367916887|9d87d7a2d26485fd926a000b0c3b2f87 – Asghar Jun 28 '12 at 10:19
  • First of all, generate a new app secret for your app right now – because you just posted your’s on the interwebs (<-stupid). And then, of course an API call to `/me` using that access token fails, because the API can’t know who “me” is supposed to be when using an _app_ access token. If the FB SDK is not giving you a user access token after login, then something went wrong. – CBroe Jun 28 '12 at 12:33

2 Answers2

1

Check this link out, scroll down to the answer with the following in bold: "When using your Facebook Application's token", hope it helps.

Facebook access_token invalid?

Community
  • 1
  • 1
David Cheung
  • 848
  • 4
  • 8
0

Change your graph call's api ('/me') by ('/[number or name id]')