我想在我的php项目中获取页面提要更新。如此。
1)我已经为facebook帐户创建了测试页面,并获得了{page_id}
2)我创建了应用帐户并获得了{app_id}和{secret}
3)创建了注册程序
$appId = Yii::app()->facebook->appId;
$secret = Yii::app()->facebook->secret;
$access_token = $appId."|".$secret;
Yii::app()->facebook->setAccessToken($access_token);
$callbackURL = "http://".$_SERVER['SERVER_NAME']."/callbackfb";
$result = Yii::app()->facebook->api("/".Yii::app()->facebook->appId."/subscriptions",'POST',
array(
'object' => 'page',
'callback_url' => $callbackURL,
'fields' => 'feed',
'verify_token' => $this->verifyToken));
和回调
$method = Yii::app()->request->getRequestType();
if($method == "GET")
{
// answering to fb, that this is callback url, it is working and all ok
Yii::log("GET request to callback","warning","facebook");
if (isset($_GET["hub_verify_token"]) && $_GET["hub_verify_token"] == $this->verifyToken && isset($_GET["hub_challenge"]))
$this->_sendResponse(200,$_GET["hub_challenge"]);
else $this->_sendResponse(400,"Fail");
} elseif ($method == "POST")
{
Yii::log("POST request to callback","warning","facebook");
// my update code
}
4)名为registerfb(一切正常 - 已成功注册,我可以看到' GET'请求回复日志文件)
5)在使用" manage_pages"在图表浏览器中生成{temp_access_token}之后和" publish_actions"权限。
6)请求http://graph.facebook.com// {user-id} / accounts?access_token = {temp_access_token}给了我{page_access_token}
7)按要求https://graph.facebook.com/ {page_id} / tabs?method = post& app_id = {app_id}& access_token = {page_access_token}我已将我的应用安装到页面
但是。出了点问题。当我发布到页面时,没有来自Facebook的请求。我尝试通过图形api在页面上发布,但没有收到更新。
问题在于犯了错误。