实时签入页面?
无法弄清楚如何通过实时 API 进行页面签入。 Facebook 表示可以通过 API 进行页面签入,但我没有看到 appid 如何与 pageid 连接。我确实已将我的应用程序添加到我想要跟踪的页面中。这是我正在处理的代码:
// Please make sure to REPLACE the value of VERIFY_TOKEN 'abc' with
// your own secret string. This is the value to pass to Facebook
// when add/modify this subscription.
define('VERIFY_TOKEN', 'acheckin');
$method = $_SERVER['REQUEST_METHOD'];
// In PHP, dots and spaces in query parameter names are converted to
// underscores automatically. So we need to check "hub_mode" instead
// of "hub.mode".
if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe' &&
$_GET['hub_verify_token'] == VERIFY_TOKEN)
{
echo $_GET['hub_challenge'];
exit;
} else if ($method == 'POST')
{
//$updates = json_decode(file_get_contents("php://input"), true);
$message = 'wedidit!';//file_get_contents("php://input");
mail('[email protected]', 'test', $message);
error_log('updates = ' . print_r($updates, true));
exit;
} else if ($method == 'GET' && $_GET['check_subscription'] == 'true' )
{
require_once 'facebook/facebook.php';
$facebook = new Facebook(array(
'appId' => '284647438227103',
'secret' => '162817ff51aacfb7c0d1420ee0f687ef'
));
$access_token = $facebook->getAccessToken();
$param = array('access_token' => $access_token);
$subs = $facebook->api('/284647438227103/subscriptions', $param);
var_dump($subs);
$message = 'checkemail';//file_get_contents("php://input");
mail('[email protected]', 'test', $message);
error_log('checkingerrorlog');
exit;
}
require_once 'facebook/facebook.php';
$facebook = new Facebook(array(
'appId' => '284647438227103',
'secret' => '162817ff51aacfb7c0d1420ee0f687ef'
));
$access_token = $facebook->getAccessToken();
$param = array('access_token' => $access_token,
'object' => 'page',
'fields' => 'checkins',
'callback_url' => 'http://www.ivanmayes.com/arduino/checkins/checkins.php',
'verify_token' => 'acheckin'
);
$subs = $facebook->api('/284647438227103/subscriptions', 'POST', $param);
cannot figure out how to get page checkins working through the real time api. Facebook says that page checkins are available through the API, but i'm not seeing how the appid connects with pageids. I do have my application added to the page i want to track. Here is the code I'm working against:
// Please make sure to REPLACE the value of VERIFY_TOKEN 'abc' with
// your own secret string. This is the value to pass to Facebook
// when add/modify this subscription.
define('VERIFY_TOKEN', 'acheckin');
$method = $_SERVER['REQUEST_METHOD'];
// In PHP, dots and spaces in query parameter names are converted to
// underscores automatically. So we need to check "hub_mode" instead
// of "hub.mode".
if ($method == 'GET' && $_GET['hub_mode'] == 'subscribe' &&
$_GET['hub_verify_token'] == VERIFY_TOKEN)
{
echo $_GET['hub_challenge'];
exit;
} else if ($method == 'POST')
{
//$updates = json_decode(file_get_contents("php://input"), true);
$message = 'wedidit!';//file_get_contents("php://input");
mail('[email protected]', 'test', $message);
error_log('updates = ' . print_r($updates, true));
exit;
} else if ($method == 'GET' && $_GET['check_subscription'] == 'true' )
{
require_once 'facebook/facebook.php';
$facebook = new Facebook(array(
'appId' => '284647438227103',
'secret' => '162817ff51aacfb7c0d1420ee0f687ef'
));
$access_token = $facebook->getAccessToken();
$param = array('access_token' => $access_token);
$subs = $facebook->api('/284647438227103/subscriptions', $param);
var_dump($subs);
$message = 'checkemail';//file_get_contents("php://input");
mail('[email protected]', 'test', $message);
error_log('checkingerrorlog');
exit;
}
require_once 'facebook/facebook.php';
$facebook = new Facebook(array(
'appId' => '284647438227103',
'secret' => '162817ff51aacfb7c0d1420ee0f687ef'
));
$access_token = $facebook->getAccessToken();
$param = array('access_token' => $access_token,
'object' => 'page',
'fields' => 'checkins',
'callback_url' => 'http://www.ivanmayes.com/arduino/checkins/checkins.php',
'verify_token' => 'acheckin'
);
$subs = $facebook->api('/284647438227103/subscriptions', 'POST', $param);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论