[英]Facebook Page Likes and its information getting API returned empty data
I have seen similar posts on this site, but none has solved my problem, the api version has changed and some endpoints are deprecated. 我在这个网站上看过类似的帖子,但没有一个解决了我的问题,api版本已经改变,一些端点已被弃用。
When I use, even the Graph API Explorer I get a response with empty data. 当我使用时,即使是Graph API Explorer,我也会得到一个空数据的响应。
// Instantiating the Facebook class
$this->api = new Facebook([
'app_id' => $ apiId,
'app_secret' => $ apiSecret,
'default_graph_version' => 'v2.11',
]);
....
// Creating the authentication link
$helper = $this->api->getRedirectLoginHelper();
$permissions = ['manage_pages', 'publish_pages', 'read_insights']; // Optional permissions
$loginUrl = $helper->getLoginUrl ('http://dev2.example.co/smms/index.php?id=16', $permissions);
...
// Getting the total of likes of the page (the endpoint 'fan_count' does not work for this version)
$this->api->get('/'.$this->id_profile.' / likes', $this->getAccessTokenAttribute())
The result is empty and the access token is correct in all cases. 结果为空,访问令牌在所有情况下都是正确的。
On the other hand, when I make the call to only the information on the page, it only delivers the data of the name of the page and the id 另一方面,当我只调用页面上的信息时,它只传递页面名称和id的数据
protected 'decodedBody' =>
array (size = 2)
'name' => string 'Test Page' (length = 9)
'id' => string '1989831694572991' (length = 16)
I would appreciate if you could guide me to get all the information on the page as the likes. 如果您能指导我获取页面上的所有信息,我将不胜感激。 I do not know if any page level permission is missing in order to achieve it. 我不知道是否缺少任何页面级别权限才能实现它。
I am working with TYPO3 7.6 and PHP 5.6. 我正在使用TYPO3 7.6和PHP 5.6。
Change likes to fan_count 改变喜欢fan_count
$this->api->get('/'.$this->id_profile.'?fields=fan_count', $this->getAccessTokenAttribute());
I think fans_count
is working in v2.11. 我认为fans_count
正在fans_count
中工作。 If its not working for you then kindly share some more code for inspection 如果它不适合您,那么请分享一些更多的代码进行检查
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.