Val*_*eri 3 facebook facebook-graph-api facebook-insights
我从Facebook Graph API获得的数据来自Facebook Graph API超过一年.而最近开始了我的所有请求(像{id}/insights)带一个错误返回:(#190) This method must be called with a Page Access Token.但Access令牌包含范围manage_pages,read_insights.有任何想法吗?
Ach*_*dja 11
manage_pages,read_insights
这将为用户提供access_token可用于管理页面和检查见解的用户,
但是/insights自2018年5月5日以来,任何端点都需要页面令牌
使用您的manage_pages范围并user_token获取页面访问令牌
向此端点发送get请求
GET /{page-id}?fields=access_token
Run Code Online (Sandbox Code Playgroud)
产量
{
"access_token": "{your-page-access-token}",
"id": "{page-id}"
}
Run Code Online (Sandbox Code Playgroud)
您现在可以使用返回的访问令牌来调用/insights端点.
As I cant add comment I'll write it here.
Field name is access_token which you can check here with your page id.
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.
Run Code Online (Sandbox Code Playgroud)
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.
| 归档时间: |
|
| 查看次数: |
6375 次 |
| 最近记录: |