无法通过发布到 api 来签入 Facebook 地方信息?

发布于 2024-10-11 19:48:27 字数 1442 浏览 2 评论 0原文

我正在尝试构建一个应用程序,让我的注册用户能够在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

≈。彩虹 2024-10-18 19:48:27

你的答案几乎是正确的。

$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' => json_encode(array(
   'latitude'  => 'lattiude',
   'longitude' => 'lattitude',
   'tags' => $uid),
 )
)

请注意,对于坐标,您必须提供 json_encode 变量。
希望对某人有帮助。

Your answer is almost correct.

$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' => json_encode(array(
   'latitude'  => 'lattiude',
   'longitude' => 'lattitude',
   'tags' => $uid),
 )
)

Notice that for coordinates you have to supply a json_encode variable.
Hope that helps someone.

握住你手 2024-10-18 19:48:27

只是来自 Facebook 的更新:

注意:不推荐发布 Checkin 对象,而是创建附加位置的 Post。

您可以在此处查看如何创建带有位置(或 Facebook 地点 ID)的帖子:
http://developers.facebook.com/docs/reference/api/user/ #帖子

Just an update From Facebook:

NOTE: Publishing a Checkin object is deprecated in favor of creating a Post with a location attached.

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文