Reputation: 1561
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?
Upvotes: 24
Views: 22490
Reputation: 167
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);
Upvotes: 5
Reputation: 555
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/
Upvotes: 7
Reputation: 4493
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
Upvotes: 6
Reputation: 57766
I have tried for hour but I think there needs to add new bug report. It was working year before as posted by Debjit.
Have updated on following posts:
Upvotes: 2
Reputation: 69
Yes it is possible in this format: @[{user_id}:1:{name}]
Try this tutorial: http://digitizor.com/2011/01/24/tag-user-facebook-graph/
Upvotes: 6