0

I'd just like to ask about a problem I'm facing with Facebook Graph API. I've connected to Facebook successfully, stored the user ID, and user access_code into my DB

Now when viewing the site I'm building, it's using the access_token stored in my database, but doesn't show my facebook statuses....because the "session has expired"....

Is there anyway I can regenerate the access_token?

Thanks

Example:

$status = 'https://graph.facebook.com/'.$userId.'/statuses?limit='.10.'&access_token='.$app_token;
4

3 回答 3

1

User access tokens last only 1-2 hours. There is a technique to get a 60 day token for your use. It is explained here: http://dominicminicoopers.blogspot.com/2012/03/facebook-access-tokens-and-offline.html Remember to get this extended access token prior to the short-lived access token expiring. You must pass in a valid working user access token to pass to it. Do this serverside, not clientside because you have to use your app secret.

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

Remember to ask for the user_status permission when prompting the user. See: http://developers.facebook.com/docs/authentication/permissions/#user_friends_perms

于 2012-07-03T15:36:29.093 回答
0

You cant regenerate it, but you can get a new one by having the user go through the oauth process again, it will return a new token - https://developers.facebook.com/docs/authentication/

于 2012-07-03T12:03:21.010 回答
0

You can try to get a long lived token. That will allow you to access the status even when the user is not loged in. See here

于 2012-07-03T12:07:40.207 回答