实时签入页面?

发布于 2024-12-11 09:06:24 字数 2603 浏览 0 评论 0原文

无法弄清楚如何通过实时 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文