如何订阅 Facebook 页面墙的实时更新

问题描述:

Facebook 的 实时更新文档 现在说您可以获得页面的提要:

Facebook's real-time updates docs now say that you can get the feed for a page:

您可以像订阅一样订阅页面的提要用户的提要 - 订阅主题应该是用户",并且订阅字段应为提要"

You can subscribe to the page's feed in the same way you subscribe to a user's feed - the subscription topic should be 'user' and the subscription field should be 'feed'

我对此的理解是,我需要发布到图形 API 以这样订阅:

My understanding of this is that I need to post to the graph API to subscribe as such:

curl -d 
"object=user&fields=feed&callback_url=$CALLBACKURL&verify_token=$SECRET" 
"https://graph.facebook.com/$PAGEID/subscriptions?access_token=$OAUTHTOKEN"

(这是一个 bash 脚本.)这里 $CALLBACKURL 按照他们的 示例代码.(至少我认为它是正确的——我可以用它成功添加订阅.)$OAUTHTOKEN 是我的 Facebook 应用程序的代码.
$PAGEID 是我想要实时更新的页面的 Facebook 对象 ID.

(This is a bash script.) Here $CALLBACKURL is set up correctly following their example code. (At least I think it's correct -- I can successfully add subscriptions with it.) The $OAUTHTOKEN is the one for my Facebook App.
And the $PAGEID is the facebook object id of the page I'd like to get realtime updates for.

当我执行此操作时,该调用似乎有效 - 没有错误消息.我的回调被调用.但是当页面的提要上发生某些事情时,我当然不会收到通知.

When I do this, the call appears to work -- no error message. My callback gets called. But I certainly don't get notified when something happens on the page's feed.

那么缺少什么?该页面是否需要安装我正在使用其 oauth 令牌的应用程序?或者我是否需要通过以页面身份登录来获取 页面 本身的 oauth 令牌?

So what's missing? Does the page need to install the app whose oauth token I'm using? Or do I somehow need to get an oauth token for the page itself by logging in as the page?

我不知道这是否对您有帮助,但我会告诉您我在哪里进行实时更新页面提要:

I do not know if this can help you but I'll tell you where I am for real-time update page feed:

(权限:manage_page、offline_access、read_stream)

(permissions : manage_page,offline_access,read_stream)

  1. 您的应用程序必须链接到页面(然后安装应用程序,但不需要有一个选项卡,例如创建选项卡 https://graph.facebook.com/PAGE_ID/tabs?app_id=APP_ID&method=POST&access_token=PAGE_ACCESS_TOKEN 并删除标签TAB_ID=PAGE_ID.'/tabs/app_'.APP_ID;https://graph.facebook.com/TAB_ID?method=DELETE&access_token=PAGE_ACCESS_TOKEN)

  1. your application must be linked to the page (then install the application but not required to have a tab ex. create tab https://graph.facebook.com/PAGE_ID/tabs?app_id=APP_ID&method=POST&access_token=PAGE_ACCESS_TOKEN and delete tab TAB_ID=PAGE_ID.'/tabs/app_'.APP_ID; https://graph.facebook.com/TAB_ID?method=DELETE&access_token=PAGE_ACCESS_TOKEN)


function page_access_token($page_id,$access_token){
$page_token_url="https://graph.facebook.com/" . $page_id . "?fields=access_token&" . $access_token; $response = file_get_contents($page_token_url); $resp_obj = json_decode($response,true); $page_access_token = $resp_obj['access_token']; return $page_access_token; }

function page_tabs_create($page_id,$app_id,$page_access_token){

function page_tabs_create($page_id,$app_id,$page_access_token){

$page_settings_url = "https://graph.facebook.com/" .$page_id ."/tabs?app_id=".$app_id."&method=POST&access_token=".$page_access_token;$response = file_get_contents($page_settings_url);$resp_obj = json_decode($response,true);返回 $resp_obj;}

$page_settings_url = "https://graph.facebook.com/" . $page_id . "/tabs?app_id=".$app_id."&method=POST&access_token=" . $page_access_token; $response = file_get_contents($page_settings_url); $resp_obj = json_decode($response,true); return $resp_obj; }

function page_tabs_delete($tab_id,$page_access_token){

function page_tabs_delete($tab_id,$page_access_token){

$page_settings_url = "https://graph.facebook.com/".$tab_id."?方法=DELETE&access_token=".$page_access_token;$response = file_get_contents($page_settings_url);$resp_obj = json_decode($response,true);

$page_settings_url = "https://graph.facebook.com/".$tab_id."?method=DELETE&access_token=" . $page_access_token; $response = file_get_contents($page_settings_url); $resp_obj = json_decode($response,true);

返回 $resp_obj;}

return $resp_obj; }

订阅:订阅必须像一个用户",因此对象=用户字段=提要但你必须添加新字段,否则它会收到评论并喜欢墙,所以你必须在其中添加状态"为了接收发布的文章(我的问题是获取其他内容,例如链接,我已设法将链接"添加为字段,但在发布链接时我没有收到通知)

Subscription: to subscribe must be like a "user" and therefore object = user fields = feed but you have to add new fields because otherwise it receives the comments and likes the wall so you must add "status" in order to receive the articles posted (my problem is to get other content such as links I have managed to add "link" as fields but I am not receiving notifications when a link is posted)

$param = array ('access_token' => $ access_token,'对象' => '用户','fields' => '提要、状态、链接''callback_url' => 'http://******** fbcallback.php''verify_token' =>'***********','include_values' => '真');

$param = array ('access_token' => $ access_token, 'object' => 'user', 'fields' => 'feed, status, link' 'callback_url' => 'http:// ******** fbcallback.php' 'verify_token' =>'***********', 'include_values' => 'true');

发布https://graph.facebook.com/APP_ID/subscriptions

我的英语不是很好,但我希望它能帮到你,在我这边,我仍在寻找墙上的所有更新(链接、视频......)

my English is not very good but I hope it will help you, on my side I'm still looking for really all updates to the wall (links, video ...)