Php 页面/提要的Facebook API实时更新无响应

Php 页面/提要的Facebook API实时更新无响应,php,facebook,facebook-graph-api,real-time,facebook-requests,Php,Facebook,Facebook Graph Api,Real Time,Facebook Requests,我的Facebook页面上的Facebook实时订阅有问题 当我发布订阅时,我会将facebook上的信息发送到我的回拨url。 代码: $session=newfacebooksession(“”); $request=新facebook请求( $session, "岗位",, “//订阅”, 排列( '对象'=>'页面', 'callback_url'=>'http://**************/facebook/callback.php', 'fields'=>'conversatio

我的Facebook页面上的Facebook实时订阅有问题

当我发布订阅时,我会将facebook上的信息发送到我的回拨url。 代码:

$session=newfacebooksession(“”);
$request=新facebook请求(
$session,
"岗位",,
“//订阅”,
排列(
'对象'=>'页面',
'callback_url'=>'http://**************/facebook/callback.php',
'fields'=>'conversation',//尝试输入'feed'到
'验证\u令牌'=>'',
)
);
$response=$request->execute();
但当有人向我的fb页面添加帖子/对话时,facebook不会向我发送任何数据

callback.php代码:

<?php

// Insert the path where you unpacked log4php
include('log4php/Logger.php');

// Tell log4php to use our configuration file.
Logger::configure('config.xml');

// Fetch a logger, it will inherit settings from the root logger
$log = Logger::getLogger('myLogger');

// Start logging
$log->warn($_REQUEST);   // Logged because WARN >= WARN

require_once __DIR__ . '/facebook-php-sdk-v4-5.0-dev/src/Facebook/autoload.php';

use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\Authentication\AccessToken;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;

//define('VERIFY_TOKEN', '*******');

$method = $_SERVER['REQUEST_METHOD'];





if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe' && $_GET['hub_verify_token'] == '<VERIFY TOKEN>') {
    echo $_GET['hub_challenge'];
    $log->warn($_GET);
    $log->warn($_POST);
} else if ($method == 'POST') {
    $updates = json_decode(file_get_contents("php://input"), true);
    // Here you can do whatever you want with the JSON object that you receive from FaceBook.
    // Before you decide what to do with the notification object you might aswell just check if
    // you are actually getting one. You can do this by choosing to output the object to a textfile.
    // It can be done by simply adding the following line:
    // file_put_contents('/filepath/updates.txt',$updates, FILE_APPEND);

    $log->warn($updates);
    $log->warn($_GET);
    $log->warn($_POST);
    error_log('updates = ' . print_r($obj, true));
}
warn($_请求);//已记录,因为WARN>=WARN
需要一次目录/facebook-php-sdk-v4-5.0-dev/src/facebook/autoload.php';
使用Facebook\FacebookSession;
使用Facebook\FacebookRequest;
使用Facebook\Authentication\AccessToken;
使用Facebook\GraphUser;
使用Facebook\FacebookRequestException;
//定义('VERIFY_TOKEN','********');
$method=$\u服务器['REQUEST\u method'];
如果($method=='GET'&&$'u GET['hub\u mode']=='subscribe'&&$'u GET['hub\u verify\u token']=''){
echo$_获得['hub_challenge'];
$log->warn($\u GET);
$log->警告($\u POST);
}如果($method=='POST',则为else){
$updates=json\u decode(文件\u获取\u内容(“php://input"(对),;
//在这里,您可以对从FaceBook接收的JSON对象执行任何操作。
//在决定如何处理通知对象之前,不妨先检查
//您实际上得到了一个。您可以通过选择将对象输出到文本文件来实现这一点。
//只需添加以下行即可完成此操作:
//文件内容('/filepath/updates.txt',$updates,file\u APPEND);
$log->warn($updates);
$log->warn($\u GET);
$log->warn($\u POST);
错误日志('updates=')。打印($obj,true));
}

谢谢你的帮助

Facebook支持目前存在一个开放性bug:


所以这可能是一个暂时的问题…

订阅/{your app id}/subscriptions的输出是什么

根据您的代码,您订阅了需要读取页面邮箱权限的/conversations。您可能想先尝试一个简单的页面订阅,看看这是否有效


RTU更新似乎从昨天开始恢复正常,但删除您的订阅并重新订阅可能也值得一试,因为昨天RTU出现问题时,您可能订阅了一个黑洞。

我在facebook开发者论坛朋友的大力帮助下找到了答案:)

我的代码使订阅和回调代码都很好。但仅仅获得对话或反馈是不够的。我必须使用graph api中的请求将我的应用程序作为订阅的应用程序添加到我的页面: 邮递 {page id}/订阅的应用程序

此操作的文档位于:

是的,这是可能的,我必须等待,然后检查。感谢您的回复;)FaceBook支持上的问题现在已经解决,但我的回调仅在创建新订阅时使用[hub_mode]、[hub_challange]和[hub_verify_token]获取数据。当我的页面(评论、帖子或消息)发生变化时,回拨为空。。。
<?php

// Insert the path where you unpacked log4php
include('log4php/Logger.php');

// Tell log4php to use our configuration file.
Logger::configure('config.xml');

// Fetch a logger, it will inherit settings from the root logger
$log = Logger::getLogger('myLogger');

// Start logging
$log->warn($_REQUEST);   // Logged because WARN >= WARN

require_once __DIR__ . '/facebook-php-sdk-v4-5.0-dev/src/Facebook/autoload.php';

use Facebook\FacebookSession;
use Facebook\FacebookRequest;
use Facebook\Authentication\AccessToken;
use Facebook\GraphUser;
use Facebook\FacebookRequestException;

//define('VERIFY_TOKEN', '*******');

$method = $_SERVER['REQUEST_METHOD'];





if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe' && $_GET['hub_verify_token'] == '<VERIFY TOKEN>') {
    echo $_GET['hub_challenge'];
    $log->warn($_GET);
    $log->warn($_POST);
} else if ($method == 'POST') {
    $updates = json_decode(file_get_contents("php://input"), true);
    // Here you can do whatever you want with the JSON object that you receive from FaceBook.
    // Before you decide what to do with the notification object you might aswell just check if
    // you are actually getting one. You can do this by choosing to output the object to a textfile.
    // It can be done by simply adding the following line:
    // file_put_contents('/filepath/updates.txt',$updates, FILE_APPEND);

    $log->warn($updates);
    $log->warn($_GET);
    $log->warn($_POST);
    error_log('updates = ' . print_r($obj, true));
}