通过 Facebook API 在状态更新中标记好友

发布于 2024-10-05 10:03:47 字数 1688 浏览 3 评论 0原文

我最近遇到这篇博文 说可以通过 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 技术交流群。

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

发布评论

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

评论(5

二货你真萌 2024-10-12 10:03:47

上周我一直在努力解决这个问题,并发现了以下错误报告,该报告表明(鉴于当前的已分配状态)它还无法完成:(

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/

情仇皆在手 2024-10-12 10:03:47

是的,可以采用以下格式:@[{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/

半边脸i 2024-10-12 10:03:47

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

满天都是小星星 2024-10-12 10:03:47

下面的代码对我有用,如果您不想在帖子中显示地点,请尝试使用我提到的相同代码 $params['place']='155021662189'; 该代码不会显示邮政的地方

             $params=array();       

             $params['message'] = "Hi Friends ";
             $params['tags']='12345678903,1234567654'; //comma separated friends ID's
             $params['place']='155021662189'; 

             $params['name'] = "Some namee";
             $params['link'] = "http://blaha.com";
             $params['description'] = "blah blah blah blah";
             $params['picture'] = "image link"; 
             $params['caption'] = "Join ";


            $shared=$facebook->api("/".$user['id']."/feed", "post", $params);
                         or 
                    $shared=$facebook->api("/me/feed", "post", $params);  

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

             $params=array();       

             $params['message'] = "Hi Friends ";
             $params['tags']='12345678903,1234567654'; //comma separated friends ID's
             $params['place']='155021662189'; 

             $params['name'] = "Some namee";
             $params['link'] = "http://blaha.com";
             $params['description'] = "blah blah blah blah";
             $params['picture'] = "image link"; 
             $params['caption'] = "Join ";


            $shared=$facebook->api("/".$user['id']."/feed", "post", $params);
                         or 
                    $shared=$facebook->api("/me/feed", "post", $params);  
淡紫姑娘! 2024-10-12 10:03:47

我已经尝试了几个小时,但我认为需要添加新的错误报告。正如 Debjit 所发布的那样,它是一年前工作的。

您应该向 Facebook 提交错误报告。 (如果不存在)。

已更新以下帖子:

  1. 如何标记用户在 Facebook 应用程序的应用程序帖子中
  2. 在 Facebook 帖子中标记人员?
  3. 在以下位置标记用户使用 Facebook API 进行墙贴/更新
  4. 如何让用户在 Facebook 页面标签发布的 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:

  1. how to tag users in application post of a facebook application
  2. Tagging people in a Facebook Post?
  3. Tagging a user in a wall post/update using Facebook API
  4. How to let users tag their friends in a Facebook status update posted from a tab on a Facebook page?
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文