Facebook 实时更新未按预期运行
我注册了实时更新功能并验证了它,这是我尝试查看我的订阅是否成功时得到的响应
{ "data": [ { "object": "user", "callback_url": "http://ghl.raiseit-bd.com/callback-page.php", "fields": [ "feed" ], "active": true } ] }
现在,当我在墙上发帖时,我期望 facebook 会调用我的回调url 和内容将被写入一个文本文件
这是回调页面.php 的代码,
<?php $method = $_SERVER['REQUEST_METHOD']; if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe' && $_GET['hub_verify_token'] == 'Our1stFBApp') { echo $_GET['hub_challenge']; exit; } else { $updates = json_decode(file_get_contents("php://input"), true); $myFile = "testFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $updates; $stringData = $stringData.'Hello'; fwrite($fh, $stringData); fclose($fh); print_r($stringData, true)); } ?>
文件 textFile.txt 驻留在根目录中。
但该文件中没有写入任何内容。 我如何知道实时更新功能正在运行......任何帮助将不胜感激
I registered for real time updates feature and I verified it as well here's the response which I get when I tried to see whether my subscription was success or not
{ "data": [ { "object": "user", "callback_url": "http://ghl.raiseit-bd.com/callback-page.php", "fields": [ "feed" ], "active": true } ] }
Now when I made a post on my wall, I was expecting that facebook will call my callback url and things will get written to a text file
Here's code for callback-page.php
<?php $method = $_SERVER['REQUEST_METHOD']; if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe' && $_GET['hub_verify_token'] == 'Our1stFBApp') { echo $_GET['hub_challenge']; exit; } else { $updates = json_decode(file_get_contents("php://input"), true); $myFile = "testFile.txt"; $fh = fopen($myFile, 'w') or die("can't open file"); $stringData = $updates; $stringData = $stringData.'Hello'; fwrite($fh, $stringData); fclose($fh); print_r($stringData, true)); } ?>
the file textFile.txt resides inside root directory.
But nothings getting written in that file.
How will I know that the real-time update feature is working..any help would be greatly appreciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论