简体   繁体   English

Facebook PHP SDK获取页面帖子数据为空

[英]Facebook PHP SDK get page posts data is empty

I'm having a strange problem with the Facebook PHP SDK, 我在使用Facebook PHP SDK时遇到了一个奇怪的问题,

$response = $this->getConnection()->get("me/posts");
$feedEdge = $response->getGraphEdge();
var_dump($response); exit;

the getConnection() call provides me with a \\Facebook\\Facebook object with the default_access_token set but this works as I get a response from Facebook getConnection()调用为我提供了一个\\Facebook\\Facebook对象,该对象具有default_access_token设置,但是当我收到Facebook的响应时,此方法起作用

But the body from the above var_dump gives: 但是上面var_dump的主体给出:

["decodedBody":protected]=>
  array(1) {
    ["data"]=>
    array(0) {
    }
  }

What is really strange is when I use the Graph Explorer (as my Application and using the same Page) I see all the posts. 真正奇怪的是,当我使用Graph Explorer (作为我的应用程序并使用同一页面)时,我看到了所有帖子。 So I thought maybe it was the access token was not working correctly so I copied and pasted the access token shown in from the graph explorer into my get() call to override the default like below unfortunately this did not work and I got exactly the same output. 所以我想可能是访问令牌无法正常工作,所以我将图浏览器中显示的访问令牌复制并粘贴到我的get()调用中,以覆盖默认值,如下所示,不幸的是,这没有用,我得到了完全相同输出。

$response = $this->getConnection()->get("me/posts", "EAA....");
$feedEdge = $response->getGraphEdge();
var_dump($response); exit;

使用我的应用程序和访问令牌显示Facebook图形

So I'm unsure why the same token in one place would get the information when in another it would get an empty set the worst part is it's not like the Request is failing as that throws an exception it is like Facebook Graph API is reacting differently for my application when using the PHP-SDK verses using the Explorer. 所以我不确定为什么同一地方的同一个令牌会在另一地方得到信息,而在另一个地方会得到一个空集,最糟糕的部分是这不是因为请求失败而引发异常,就像Facebook Graph API做出不同的反应一样当使用浏览器使用PHP-SDK时,为我的应用程序提供支持

So after hours of messing around testing stuff in the Graph API Explorer and the API I worked out, there is a problem with /me/posts endpoint when using the PHP SDK even if your using a manage_pages access_token it seems to lock on to the user that instead of the page unlike the graph explorer that the /me/posts, posts to the entity of the access_token . 因此,在经过数小时的Graph API Explorer和我计算出的API的测试工作之后,使用PHP SDK时/me/posts端点存在问题,即使您使用manage_pages access_token似乎已锁定用户与/ me / posts不同,它不同于页面浏览器,而不是页面,而是发布到access_token的实体。

So make sure to request /{page_id|user_id}/posts and it works correctly. 因此,请确保请求/{page_id|user_id}/posts ,它可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM