質問

I'm working on a social alarm clock, that lets you login on facebook through a smartphone application. Next thing to do is show your facebook feed on a seperate website. So when I store the user access token on login, would I be able to fetch data from facebook api with only the access token, without the user logged in?

Thanks!

役に立ちましたか?

解決

Yes of can perform activities on behalf of user if you have an active user's access token.

But this token will expire soon. So may be you can extend this token on the server side, then it will have the expiration of 60 days. But before it expires make sure you refresh the token else it become invalidate again.

Read this documentation to know more about access tokens and its extension.

他のヒント

Finally found the solution! When a user logs in, I recieve a short-live token, I then make an ajax call to a php file, which gets me a long-live token by using

  $facebook->setExtendedAccessToken();
  $accessToken = $facebook->getAccessToken();

Next i'm storing the $accessToken (this is the long-live one) in the database. Then on my alarmclock (just another website) I fetch the token from the database (ajax) and I can start making API calls on behalf of the user, without him being logged in!

Hope I also helped other people with this! If you have any questions, just aske me, i'm kinda getting good at this :)!

Thanks for your help!

Cheers

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top