开发者

Getting a user's ID using Facebook's Graph API

开发者 https://www.devze.com 2023-03-30 05:37 出处:网络
Is it possible to get the ID (Facebook Graph API) of a user who is currently logged in, without any access tokens?

Is it possible to get the ID (Facebook Graph API) of a user who is currently logged in, without any access tokens?

If not, then how do I get new access tokens every time a user visits m开发者_如何学Goy page?


You will need to init the Facebook Javascript SDK and the user will have to have authorized your app at least one time. After that when the user visits your page as long as they are logged into Facebook you'll have access to the id and can retrieve it using

FB.getLoginStatus

the response will contain the information you're looking for.

Check this blog post for more details on setting up the FB init and the initial login.

https://developers.facebook.com/blog/post/525/


  1. You can check the facebook ID using their username

    http://graph.facebook.com/radrivan

  2. You can use the javascript sdk to get their accesstoken and let them allow your app.

https://developers.facebook.com/docs/facebook-login/login-flow-for-web/v2.2

0

精彩评论

暂无评论...
验证码 换一张
取 消