Can't checkin to Facebook Places by post to api?
Posted
by
MarcusJoe
on Stack Overflow
See other posts from Stack Overflow
or by MarcusJoe
Published on 2011-01-15T01:45:59Z
Indexed on
2011/01/15
1:53 UTC
Read the original article
Hit count: 559
Hey everybody,
I am trying to build an app where I let my registered user be able to check in to places on Facebook Places. I however for some reason can't seem to make this work. I assumed this is possible with the Api as write functionality has been added to it, but I couldn't find an clear explanation on the web. this is what I currently have, after I have asked the user for permission to publish checkins and for user_checkins.
<?php
require("src/facebook.php");
$facebook = new Facebook(array(
'appId' => 'xxxxxxxxx',
'secret' => 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
'cookie' => true
));
# see if active session
$session = $facebook->getSession();
if(!empty($session)) {
try{
$uid = $facebook->getUser();
$api_call = array(
'method' => 'users.hasAppPermission',
'uid' => $uid,
'ext_perm' => 'publish_checkins'
);
$can_post = $facebook->api($api_call);
if($can_post){
$facebook->api('/'.$uid.'/checkins', 'POST', array(
'access_token' => $facebook->getAccessToken(),
'place' => 'place_id',
'message' =>'I went to placename today',
'picture' => 'http://www.place.com/logo.jpg',
'coordinates' => array(
'latitude' => 'lattiude',
'longitude' => 'lattitude',
'tags' => $uid,
)
)
);
echo 'You were checked in';
} else {
die('Permissions required!');
}
} catch (Exception $e){}
} else {
# There's no active session,generate one
$login_url = $facebook->getLoginUrl();
header("Location: ".$login_url);
}
?>
The code works when I change it 'checkins' to 'feed'. Is there something wrong with my code or am I trying to do somethign that isn't possible (or do it the wrong way).
Any help will be greatly appreciated as I already spent quite a significant amount of time trying to fix this, but I just can't seem to make it work.
Best regards,
Marcus Joe
© Stack Overflow or respective owner