0

is there a way to check if a user checked into a particular place at any time in the past?

with php sdk, i can get a place info like:

$place = $facebook->api('/placeIDhere');
var_dump($place['checkins'])

this gives me the checkin count.

to get the recent checkins of a user i could do

$usercheckins = $facebook->api('/search?type=checkin');
var_dump($usercheckins[0]['place']['name']);

this gives me the last checkin by name

but is there a way to check if a user checked into a special place? /search?type=checkin only gives me a very small number of recent checkins and if a checkin is older than ~2-3 weeks it doesn't even appear.

thanks for all help.

choise
  • 24,636
  • 19
  • 75
  • 131

2 Answers2

1

Here is how to make the bkaid answer worked with the PHP SDK (see on github).

First, you have to check if the user is logged in or not :

require "facebook.php";
$facebook = new Facebook(array(
    'appId'  => YOUR_APP_ID,
    'secret' => YOUR_APP_SECRET,
));

$user = $facebook->getUser();

if ($user) {
    try {
        $user_profile = $facebook->api('/me');
    } catch (FacebookApiException $e) {
        $user = null;
    }
}

You render the link to make him log in if he is not. And if he is, you can make the API call :

if (!$user) {
    echo '<a href="' . $facebook->getLoginUrl() . '">Login with Facebook</a>';
} else {
    $fql = "SELECT post_id, message FROM checkin
            WHERE author_uid = me() AND page_id = THE_PAGE_ID";

    $response = $facebook->api(array(
        'method' => 'fql.query',
        'query' => $fql,
    ));
}

Hope that helps !

Quentin
  • 2,529
  • 2
  • 26
  • 32
0

Do a FQL query against the checkin table. Something like:

    SELECT coords,tagged_uids,author_uid,page_id,app_id,post_id,timestamp,message 
    FROM checkin 
    WHERE author_uid = me() and page_id = 'placeID'
bkaid
  • 51,465
  • 22
  • 112
  • 128
  • is there a way to do this with the new sdk version? tried something like that with no response: `$facebook->api('fql.query?query=xyz');` – choise May 27 '11 at 17:27
  • Make sure the query you run will actually return a result by testing the same query on https://developers.facebook.com/docs/reference/rest/fql.query/. Also, try a more basic query first. – bkaid May 27 '11 at 17:35
  • 1
    okay, can't get this working with the php-sdk. i used file_get_contents now with the access_token from the sdk. seems working, thanks!. i'm thankful for every hint to get this working directly with the sdk – choise May 27 '11 at 19:16