7

I want to show the last facebook post on my website. I have a script for it but it needs access token to work.

I followed the steps mentioned in this post:

https://neosmart-stream.de/de/facebook/how-to-create-a-facebook-access-token/comment-page-1/#comment-617

Now I've got an access token with an expiry period of 60 days but when I open https://graph.facebook.com/me/accounts, I get this error:

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

as my access token validity is 2 months, It is supposed to work.

Steel Brain
  • 4,321
  • 28
  • 38
user1915882
  • 79
  • 1
  • 2
  • Check the obtained token in debugger properly. This error occurs only when there's issue with the access token. Are you able to proceed with the normal access token ? – Sahil Mittal Dec 19 '12 at 13:32
  • I've checked in in debugger, Expires: (number) (in about 2 months) Valid: True Origin: Web With ne normal access token it still works – user1915882 Dec 19 '12 at 13:49

2 Answers2

7

1: Create an application in facebook with your website url

2: Run this link in your browser

3: Visit the following to generate a new SHORT-LIVED (1 hour) access token:

https://www.facebook.com?client_id=[APPID]&client_secret=[APPSECRET]&redirect_uri[http://APPURL]&scope=manage_pages,read_stream&response_type=token

4: Take that short-lived access token and send it here:

https://graph.facebook.com/oauth/access_token?client_id=[APP_ID]&client_secret=[APP_SECRET]&grant_type=fb_exchange_token&fb_exchange_token=[EXISTING_ACCESS_TOKEN]

5: Then, either in FB’s Graph API Explorer or on your own, visit here:

https://graph.facebook.com/me/accounts?access_token=[TOKEN]

Then paste the token and id in the code, then you will get the result.

You can debug and verify the expiration date of your token using the FaceBook Access Token Debugger:

Mukul Goel
  • 8,387
  • 6
  • 37
  • 77
Tapefreak
  • 982
  • 1
  • 13
  • 16
1

when i'll open https://graph.facebook.com/me/accounts...

You need to open it in the Graph API Explorer and add the access token retrieved in the earlier step or append it to end of the url

https://graph.facebook.com/me/accounts?access_token=XXXX

phwd
  • 19,975
  • 5
  • 50
  • 78
  • if i append it to end of the url, the output is: { "data": [ ] } edit: same output in Graph API Explorer – user1915882 Dec 19 '12 at 16:09
  • 1
    @user1915882 go here https://developers.facebook.com/tools/explorer/?method=GET&path=me%2Faccounts reply with what you got – phwd Dec 19 '12 at 16:12
  • { "category": "Application", "name": "Intranet-Schnittstelle", "access_token": "AAACEdEose0cBAPu2BhO66FLYa1kumLHU4g07d1tlVPzJZA5Xr5gXNIgSdPeZCZAUoUHhfyeVql6ecWvmxTKy6dyccI6GLjlXpwRNpyHeQeN68w21ySQAKFgbBOZA98QZD", "id": "189315704541822" } – user1915882 Dec 19 '12 at 16:17
  • @user1915882 maybe try redoing the auth process if that doesn't work file a bug – phwd Dec 19 '12 at 16:20