2

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('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);
Jamey Sharp
  • 8,363
  • 2
  • 29
  • 42
Ivan Mayes
  • 125
  • 1
  • 8
  • Hey Ivan. I came across this while looking for solutions for the *very same question*. Funny how that happens. As a heads up, you probably want to edit out your app secret id up there. –  Jun 25 '12 at 15:18
  • 1
    Hey Rendall. The answer to the question is that Facebook only offers checkins for the uid's own checkins or their friends checkins, making it impossible to get ALL of the checkins for a venue, unfortunately. – Ivan Mayes Jun 26 '12 at 15:55
  • But facebook doc says its possible to get checkin also with realtime api. https://developers.facebook.com/docs/reference/api/page/#realtime – Krishna Karki Aug 14 '13 at 07:33
  • Hey Krishna, it does say that, but it says user_checkins or friends_checkins. This means you can look for checkins for a specific user or for his friends, but you cannot look at checkins for a business in real time as of now. – Ivan Mayes Aug 15 '13 at 12:15
  • @IvanMayes https://developers.facebook.com/docs/graph-api/real-time-updates/v2.0 under 'Page object subscriptions' there is an attribute of `checkins`. I assume fb says it provides number of checkins for a business page – RAJ Jul 28 '14 at 13:00

0 Answers0