I get data from the Facebook insights via Facebook Graph API more than year. And recently started all my requests (like {id}/insights
) to return with an error: (#190) This method must be called with a Page Access Token
.
But the Access token contains scopes manage_pages,read_insights
.
Any ideas?
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.
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.
来源:https://stackoverflow.com/questions/48707646/facebook-graph-api-190-this-method-must-be-called-with-a-page-access-token