实时检查页面?

时间:2011-10-22 18:25:52

标签: facebook facebook-graph-api checkin

无法弄清楚如何通过实时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('ivan@ivanmayes.com', '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('ivan@ivanmayes.com', '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);

0 个答案:

没有答案