Information about current user in facebook

后端 未结 2 537
青春惊慌失措
青春惊慌失措 2021-01-26 22:15

I am trying to get facebook userid of the users currently logged in. I used this below piece of code ang got error \"Uncaught OAuthException: An active access token must be used

2条回答
  •  渐次进展
    2021-01-26 22:48

    Follow these steps:

    1. You generate an url: $next_url = $facebook->getLoginStatusUrl();
    2. redirect the user to this url: header('Location: '.$next_url);
    3. the user will be returned by FB with session information about the login status
    4. the SDK will parse the returned info
    5. use $facebook->getUser(); to get the access_token and userid (if logged in)

    So far so good. The only problem is, this function (point 4) is broken since the transition to oAuth2.0 by Facebook API, see also this bug report: http://developers.facebook.com/bugs/295348980494364

    The returned $_GET['session'] is useless in the new oAuth2.0 SDK, it was used in the old PHP-SDK v2 (current is 3.1.1).

    So please let FB know that you have the same issue by adding a reproduction.

    Cheers!

提交回复
热议问题