2

I have the scrips that redirect to the facebook's oauth dialog and need a user_checkins permission

<?php
session_start();
$app_id = "[APP_ID]";
$app_secret = "[APP_SECRET]";
$my_url = "(back to this page)";

$code = $_REQUEST["code"];

if(empty($code)) {
 $_SESSION['state'] = md5(uniqid(rand(), TRUE)); //CSRF protection
 $dialog_url = "https://www.facebook.com/dialog/oauth?client_id=" 
   . $app_id . "&redirect_uri=" . urlencode($my_url) . "&state="
   . $_SESSION['state']."&scope=user_checkins"  ;
 echo("<script> top.location.href='" . $dialog_url . "'</script>");
}

if($_REQUEST['state'] == $_SESSION['state']) {
 $token_url = "https://graph.facebook.com/oauth/access_token?"
   . "client_id=" . $app_id . "&redirect_uri=" . urlencode($my_url)
   . "&client_secret=" . $app_secret . "&code=" . $code;

 $response = @file_get_contents($token_url);
 $params = null;
 parse_str($response, $params);

$graph_url = "https://graph.facebook.com/me?fields=checkins&access_token=" 
  . $params['access_token'];

 $user = json_decode(file_get_contents($graph_url));
 echo "<pre>";
 print_r($user);
 echo "</pre>"; 
} else {
  echo("The state does not match. You may be a victim of CSRF.");
}
?>

dialog display only

THIS APP WILL RECEIVE:

■ Your basic info

but it should have one more line with checkins permission, isn't it?

so, i try to use the Graph API Explorer. First i test with my APP, the result is the same, still can't get user_checkins permission

But if i change the "Application:" section to Graph API Explorer and test again, Everything seems to be OK..

So, I think it's cause of my APP settings.. or something..

Could you please suggest me how to fix this ?

TiTi K.
  • 21
  • 3

2 Answers2

9

By the looks of it, I would say Facebook has deprecated the user_checkins and friends_checkins permissions and rolled them into user_status and friends_status.

Anyway, request the user_status permission instead, and you will now be able to read the user's checkins.

David Johnson
  • 417
  • 4
  • 8
  • That makes sense. I was stumped when everything except the checkins component was left in my app and for the life of me, could not get the permission. That helped a lot taking a load of my mind. Thanks fella. +1 – Siddharth Lele May 02 '12 at 02:51
  • Could you please show link to official document where FB says they've deprecated `friends_checkins` in favor of `friends_status` ? I can't get checkins of my friends by calling `/123456/checkins` :( – expert Jul 02 '13 at 04:44
3

there is an option to get the checkins. facebook have given other option to this.

http://developers.facebook.com/docs/reference/api/user/#posts

You can get the checkins with https://graph.facebook.com/me/posts?with=location

vishD
  • 31
  • 1