通过 Facebook API 在状态更新中标记好友
我最近遇到这篇博文 说可以通过 Facebook 应用程序(= 来自 API)在状态更新中标记某人:
但是,它似乎对我不起作用。
它以三种不同的方式进行了尝试:
$post = $facebook->api('/me/feed', 'post', array(
'access_token' => $session['access_token'],
'message' => 'Hello @[562372646:Lionel Cordier], how are you?'
));
或
$access_token = $session['access_token'];
$message = 'Hello @[562372646:Lionel Cordier], how are you?';
$curl_post = 'access_token='.$access_token.'&message='.$message;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/me/feed');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curl_post);
$data = curl_exec($ch);
curl_close($ch);
或
$access_token = $session['access_token'];
$message = 'Hello @[562372646:Lionel Cordier], how are you?';
$curl_post = 'access_token='.$access_token.'&status='.$message;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.facebook.com/method/users.setStatus');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curl_post);
$data = curl_exec($ch);
curl_close($ch);
但没有任何效果。我得到的结果是“Hello @[562372646:Lionel Cordier],你好吗?”在我的墙上。
但如果我直接在 Facebook 中输入“Hello @[562372646:Lionel Cordier], how are you?”,它就会正常工作。
我做错了什么?
I recently came across this blog post that said that it's possible to tag someone in a status update from a Facebook app (= from the API):
However, it doesn't seem to work for me.
It tried it in three different ways:
$post = $facebook->api('/me/feed', 'post', array(
'access_token' => $session['access_token'],
'message' => 'Hello @[562372646:Lionel Cordier], how are you?'
));
or
$access_token = $session['access_token'];
$message = 'Hello @[562372646:Lionel Cordier], how are you?';
$curl_post = 'access_token='.$access_token.'&message='.$message;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://graph.facebook.com/me/feed');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curl_post);
$data = curl_exec($ch);
curl_close($ch);
or
$access_token = $session['access_token'];
$message = 'Hello @[562372646:Lionel Cordier], how are you?';
$curl_post = 'access_token='.$access_token.'&status='.$message;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.facebook.com/method/users.setStatus');
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curl_post);
$data = curl_exec($ch);
curl_close($ch);
But nothing works. The result I have is "Hello @[562372646:Lionel Cordier], how are you?" on my wall.
But if I type "Hello @[562372646:Lionel Cordier], how are you?" directly in Facebook, it works correctly.
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
上周我一直在努力解决这个问题,并发现了以下错误报告,该报告表明(鉴于当前的已分配状态)它还无法完成:(
http://developers.facebook.com/bugs/395975667115722/
I was struggling with this problem last week and found the following bug report, which suggests (given the current ASSIGNED status) that it cannot be done yet:(
http://developers.facebook.com/bugs/395975667115722/
是的,可以采用以下格式:@[{user_id}:1:{name}]
尝试本教程:http://digitizor.com/2011/01/24/tag-user-facebook-graph/
Yes it is possible in this format: @[{user_id}:1:{name}]
Try this tutorial: http://digitizor.com/2011/01/24/tag-user-facebook-graph/
https://apps.facebook.com/profile_ranking 正在上传图片,您可以标记图片中的人物,但不可以在状态消息中。
标记图片中的人物
curl -F 'access_token=xxxxxx' -F 'url=https://appharbor.com/assets/images/stackoverflow-logo.png'
-F '消息=@[100000891609024:沉默杀手]'
https://graph.facebook.com/me/photos
在 Graph Api Explorer< /b>
发起通话,将 url 设置为 https://graph.facebook.com/me/photos ,
添加包含关键消息和值的字段@[100000891609024:Silient Killerz](将其替换为您的朋友 ID 和姓名)
添加另一个包含键 url 和值的字段 https://appharbor.com/assets/images/stackoverflow -标志.png
点击提交
https://apps.facebook.com/profile_ranking is uploading a picture and you can tag people in pictures not in status messages.
To Tag people in picture
curl -F 'access_token=xxxxxx' -F 'url=https://appharbor.com/assets/images/stackoverflow-logo.png'
-F 'message=@[100000891609024:Silient Killerz]'
https://graph.facebook.com/me/photos
In Graph Api Explorer
Make the call post, set url to https://graph.facebook.com/me/photos,
Add field with key message and value @[100000891609024:Silient Killerz] (replace it with your friend id and name)
Add another field with key url and value https://appharbor.com/assets/images/stackoverflow-logo.png
click submit
下面的代码对我有用,如果您不想在帖子中显示地点,请尝试使用我提到的相同代码 $params['place']='155021662189'; 该代码不会显示邮政的地方
below code worked for me , try if you don't want to show place in post then use the same code i mentioned $params['place']='155021662189'; that code won't show the place in Post
我已经尝试了几个小时,但我认为需要添加新的错误报告。正如 Debjit 所发布的那样,它是一年前工作的。
您应该向 Facebook 提交错误报告。 (如果不存在)。
已更新以下帖子:
I have tried for hour but I think there needs to add new bug report. It was working year before as posted by Debjit.
You should make bug report to facebook. (If doesn't exist).
Have updated on following posts: