Facebook PHP SDK: getting “long-lived” access token now that “offline_access” is deprecated

前端 未结 4 1314
灰色年华
灰色年华 2021-01-31 05:44

BASIC PROBLEM: I want my app to be able to make calls to the Facebook graph api about authorized users even while the user is away.

For example, I want

4条回答
  •  北荒
    北荒 (楼主)
    2021-01-31 06:33

    I finally figured this out on my own. The answer is pretty anti-climactic. It appears that newly created apps get 60 day access tokens automatically. I'm not sure if this is dependent on enabling the "depricate offline_access" setting in the Migrations section of the app settings. Leave it on to be safe.

    So at the time of writing this, you can use the PHP SDK as follows: $facebook->getAccessToken();

    (The reason my app wasn't working as expected was unrelated to the expiration of the access token.)

    Just one more thing, to get long-lived access token using PHP SDK you should call $facebook->setExtendedAccessToken(); before $facebook->getAccessToken();

提交回复
热议问题