Facebook PHP SDK 3.0 - 如何获得我的页面墙上的帖子在任何时间? [英] Facebook PHP SDK 3.0 - How to get my page wall posts at any time?
问题描述
我一直在尝试从我正在编码的应用程序的页面中阅读新闻源。
现在我有一些问题试图使用PHP SDK 3.0执行此操作。
我可以获取页面信息,但这是任何公开的。
我的问题是如何获取(阅读)页面墙上的帖子?我假设我必须授予我的应用程序发布到页面的权限,但是我该怎么做?
目前这是我有的代码
$ appId ='XXXXXXXXXXXXXXXXXX';
$ secret ='YYYYYYYYYYYYYYYYYY';
$ pageId ='ZZZZZZZZZZZZZZZZZ';
$ facebook = new Facebook(array(
'appId'=> $ appId,
'secret'=> $ secret
));
$ pageProfile = $ facebook-> api($ pageId);
$ pagePosts = $ facebook-> api($ pageId。'/ posts /');
echo'My Page profile';
print_r($ pageProfile);
echo'My Page wall';
print_r($ userPosts);
在我的页面墙下,我什么都没有。我也没有任何错误。
要访问页面的帖子,它是 / feed
而不是 / post
。那么这里是你的例子的正确版本:
requirefacebook.php;
$ facebook = new Facebook(array(
'appId'=> YOUR_APP_ID,
'secret'=> YOUR_APP_SECRET,
));
$ pageFeed = $ facebook-> api(THE_PAGE_ID。'/ feed');
然后数组 $ pageFeed
将包含25个最新帖子和链接到导航:
Array(
pre>
[data] => Array(
[0] => Array(
[id] => ...
[from] => ...
[to] => ...
[message] => ...
[icon] => ...
[type] => ...
[application] => ...
[created_time] => ...
[updated_time] => ...
)
[1] => ...
[2] = $ ...
...
[24] =&$ ...
)
[paging] => Array(
[ => https:// ...
[next] => https:// ...
)
)
希望有帮助!
I have been trying to read the news feed from a page that I have using an app that I'm coding.
Now I have had some issues trying to do this using the PHP SDK 3.0.
I am able to get the page information, but this is something that is publicly available any way.
My question is how do I get (read) the page wall posts? I'm assuming I have to grant permissions to my app to post to page, but how do I do this?
currently this is the code that I have
$appId = 'XXXXXXXXXXXXXXXXXX'; $secret = 'YYYYYYYYYYYYYYYY'; $pageId = 'ZZZZZZZZZZZZZZZZZZ'; $facebook = new Facebook(array( 'appId' => $appId, 'secret' => $secret )); $pageProfile = $facebook->api($pageId); $pagePosts = $facebook->api($pageId . '/posts/'); echo 'My Page profile'; print_r($pageProfile); echo 'My Page wall'; print_r($userPosts);
Under 'My Page wall' I don't get anything. I don't get any errors either.
解决方案To access the posts of a page, it is
/feed
and not/post
. Then, here is the correct version of your example :require "facebook.php"; $facebook = new Facebook(array( 'appId' => YOUR_APP_ID, 'secret' => YOUR_APP_SECRET, )); $pageFeed = $facebook->api(THE_PAGE_ID . '/feed');
Then the array
$pageFeed
will contain the 25 latest posts and links to navigation :Array( [data] => Array( [0] => Array( [id] => ... [from] => ... [to] => ... [message] => ... [icon] => ... [type] => ... [application] => ... [created_time] => ... [updated_time] => ... ) [1] => ... [2] => ... ... [24] => ... ) [paging] => Array( [previous] => https://... [next] => https://... ) )
Hope that helps !
这篇关于Facebook PHP SDK 3.0 - 如何获得我的页面墙上的帖子在任何时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!