Facebook Open Graph - See if User checked into a particular place some time
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 a开发者_如何学Pythonll help.
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 !
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'
精彩评论