Requesting page insight for Facebook getting error “Graph returned an error: An unknown error has occurred. ”

做~自己de王妃 提交于 2021-01-28 06:00:58

问题


$helper = $fb->getRedirectLoginHelper();
$permissions = ['email','manage_pages','pages_manage_cta','publish_pages','publish_actions']; 

giving permissions.

$loginUrl = $helper->getLoginUrl('http://localhost/Facebook/insight.php', $permissions);

echo '<a href="' . $loginUrl . '">Log in with Facebook!</a>';

facebook Insight code.

$fb->setDefaultAccessToken($accessToken);

Get user groups detail

$requestPageInsights = $fb->request('GET', '/1364467436924381/insights/, $accessToken');

//Make a batch request

$batch = ['page-insights' => $requestPageInsights];

try {
$responses = $fb->sendBatchRequest($batch);
} catch(Facebook\Exceptions\FacebookResponseException $e) {

When Graph returns an error

echo 'Graph returned an error: ' . $e->getMessage();
exit;
} catch(Facebook\Exceptions\FacebookSDKException $e) {

When validation fails or other local issues

echo 'Facebook SDK returned an error: ' . $e->getMessage();
exit;
}

Graph returned an error: An unknown error has occurred.


回答1:


Just experienced the same issue. The error seems to be with batched requests - The solution for us was to change the code to do the requests individually.



来源:https://stackoverflow.com/questions/44716169/requesting-page-insight-for-facebook-getting-error-graph-returned-an-error-an

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