2013-05-07 48 views
1

我試圖通過實時API從facebook獲取實時更新。我已經配置了我的訂閱。從facebook獲取實時api的帖子通知

{ 
    "data": [ 
    { 
     "object": "user", 
     "callback_url": "https://myappname.herokuapp.com/realtime.php", 
     "fields": [ 
     "activities", 
     "feed", 
     "is_app_user", 
     "likes", 
     "online_presence", 
     "photos", 
     "picture", 
     "status", 
     "wall_count" 
     ], 
     "active": true 
    } 
    ] 
} 

我創建了一個端點,當我收到一個post請求時,它簡單地記錄了請求。但我似乎沒有得到任何來自Facebook的電話。如果我手動發佈帖子到終點,它會記錄帖子正文json。我已經檢查過heroku日誌,但是沒有發佈post請求表單fb的蹤跡,只有我的手動請求存在。

<?php 

$method = $_SERVER['REQUEST_METHOD']; 

if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe') { 
    echo $_GET['hub_challenge']; 
} else if ($method == 'POST') { 
    $data = file_get_contents("php://input"); 
    $json = json_decode($data, true); 
    error_log("update recieved"); 
    error_log('updates = ' . print_r(json, true)); 
    pg_close($db); 
} 

?> 

我已經做了由 https://graph.facebook.com/yourappid/subscriptions?access_token=youraccesstoken&object=user&fields=feed&verify_token=yourownsecretstringsetinyourphpfile&method=post&callback_url=http://www.yourwebsite.com/facebook_subscribe.php 這回我空提示訂閱成功是指定一個回調的要求測試。

我做了幾個狀態更新和喜歡,但我沒有從fb得到任何更新。我在這裏錯過了什麼嗎?

在此先感謝。

回答