FB Graph API查询在PHP SDK中不起作用 [英] FB Graph API query doesn't work in PHP SDK

查看:85
本文介绍了FB Graph API查询在PHP SDK中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

图形API:2.4
PHP SDK:"facebook/php-sdk-v4":〜5.0"

Graph API: 2.4
PHP SDK: "facebook/php-sdk-v4": "~5.0"

我想通过PHP和PHP SDK获得有关页面的详细信息. 使用查询:

I'd like to get details about a page via PHP and the PHP SDK. Using the query:

$response = $fb->get('/' . $sPageID . '?fields=posts', $_SESSION['facebook_access_token']);

返回具有大量数据的帖子.但不幸的是错误的值:
例如,对喜欢的限制25.因此,即使一个帖子应该有150个赞,但如果我执行count ($post['likes']),结果也只会得到25个.

returns the posts with a good amount of data. But unfortunately wrong values:
The limit 25 for likes for instance applies here. So even if one post should have 150 likes, if I do an count ($post['likes']) I only get 25 as a result.

所以我尝试根据Graph Explorer更改查询 这似乎工作正常: PAGE_ID/posts?fields=likes.limit(100),message,comments,shares,picture,link,type

So I tried to change my query and according to the Graph Explorer this seems to be working fine: PAGE_ID/posts?fields=likes.limit(100),message,comments,shares,picture,link,type

现在我无法将其转换为我的PHP调用. 我收到超时和

Now I can't get this transformed into my PHP call. I receive timeouts and

致命错误:未捕获的异常'Facebook \ Exceptions \ FacebookSDKException',消息为'无法将响应从Graph转换为GraphNode,因为响应看起来像GraphEdge.尝试改用GraphNodeFactory :: makeGraphEdge().在...

Fatal error: Uncaught exception 'Facebook\Exceptions\FacebookSDKException' with message 'Unable to convert response from Graph to a GraphNode because the response looks like a GraphEdge. Try using GraphNodeFactory::makeGraphEdge() instead.' in ...

用PHP中的一个查询是否可能?或者我必须运行多个查询,每个帖子一个?

Is this possible with one query in PHP or do I have to run multiple queries, one for each post?

推荐答案

我找到了这个 answer ,并且因为此请求的结尾是GraphEdge,请尝试以下操作:

I found this answer, and if because the end of point of this request is a GraphEdge, so try this:

// Get basic info on the user from Facebook.
try {
    $response = $fb->get('/' . $sPageID . '?fields=posts', $_SESSION['facebook_access_token']);

} catch (Facebook\Exceptions\FacebookSDKException $e) {
    dd($e->getMessage());
}
$getGraphEdge = $response->getGraphEdge();

希望这对您有所帮助.

致谢.

这篇关于FB Graph API查询在PHP SDK中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆