Facebook Graph API (#190) This method must be called with a Page Access Token

心不动则不痛 提交于 2019-12-01 01:35:58
Achraf Khouadja

manage_pages,read_insights

This will give a user access_token , that u can use to manage pages & check insights,

But a page token became required for any /insights endpoint since 5th feb 2018

Use your manage_pages scope & user_token to get a Page access token

Send a get request to this endpoint

GET /{page-id}?fields=access_token 

Output

{
  "access_token": "{your-page-access-token}",
  "id": "{page-id}"
}

You can use the returned access token to call /insights endpoint now.

As I cant add comment I'll write it here.

Field name is access_token which you can check here with your page id.

https://developers.facebook.com/tools/explorer/?method=GET&path=page-id%3Ffields%3Daccess_token&version=v2.12

For PHP

If you had your script in PHP, using Facebook SDK for PHP and now it brokes, you just need to retrieve token and pass it instead of access/refresh token you were using.

//Retrieve new 'page access token'.
$token = $fbApiClient -> get( "/{$pageId}?fields=access_token") -> getGraphNode()-> asArray();

//$q is your insights query which was working until now :(
//But with page acces token it will work again.
$response = $fbApiClient -> get( $q, $token['access_token']) -> getGraphEdge();

//(...) rest of script.

I think its easily adaptable to other languages too. Also you can (and propably should) store page access token and use it wherever you need, instead of retrieving it each time.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!