Facebook PHP SDK 4.0 : Getting Long Term Access Token

前端 未结 3 1860
抹茶落季
抹茶落季 2021-02-04 19:13

I\'m trying to use the PHP sdk v4.0 to get a long term access token for PAGE management.

I\'m grabbing the access token from the user\'s login (Yes, I\'m grabbing the Pa

3条回答
  •  太阳男子
    2021-02-04 19:29

    I would not use the PHP SDK for this, you can do this easily with CURL. See this article for a detailed description with all the code you need: http://www.devils-heaven.com/extended-page-access-tokens-curl/

    If you really want to do this with the PHP SDK, there is an easy solution explained here: http://www.devils-heaven.com/facebook-access-tokens/

    You just need to call a specific function on the FacecookSession object:

    $facebookSession->getLongLivedSession();
    $request = new FacebookRequest($session, 'GET', '/PAGE-ID?fields=access_token');
    

    Btw, there is no "Page-specific User Token", but of course you need to authorize the User with the "manage_pages" permission to get access to /me/accounts - so you can get a list of the administrated Pages with all their Access Tokens. After you get that list, the only difference is that you will get a short-living Page Token with a short-living User Token and an extended one with an extended User Token.

提交回复
热议问题