无法通过发布到 api 来签入 Facebook 地方信息?
我正在尝试构建一个应用程序,让我的注册用户能够在 Facebook Places 上签到。然而,由于某种原因,我似乎无法完成这项工作。我认为 Api 可以实现这一点,因为已添加写入功能,但我在网上找不到明确的解释。在我请求用户发布签入和 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);
}
?>
当我将“checkins”更改为“feed”时,该代码可以正常工作。我的代码是否有问题,或者我是否试图做一些不可能的事情(或者以错误的方式做)。
任何帮助将不胜感激,因为我已经花了相当多的时间试图解决这个问题,但我似乎无法让它发挥作用。
最好的问候,
马库斯·乔
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的答案几乎是正确的。
请注意,对于坐标,您必须提供 json_encode 变量。
希望对某人有帮助。
Your answer is almost correct.
Notice that for coordinates you have to supply a json_encode variable.
Hope that helps someone.
只是来自 Facebook 的更新:
您可以在此处查看如何创建带有位置(或 Facebook 地点 ID)的帖子:
http://developers.facebook.com/docs/reference/api/user/ #帖子
Just an update From Facebook:
You can check out how to create a Post with a location (or a Facebook Place id) here:
http://developers.facebook.com/docs/reference/api/user/#posts