posting on a friend's wall using graph API
Solution 1
This would perhaps be the way to do it.. (Untested, but I use something similar for my app.)
$friends = $facebook->api('/me/friends');
foreach($friends['data'] as $friend) {
$facebook->api('/$friend['id']/feed', 'post', array(
'message' => 'just a test message',
'link' => 'http://site.com',
'name' => 'just a test name',
'caption' => 'just a test caption',
'description' => 'just a test description',
));
}
This is using the PHP API.
Solution 2
I just did a little testing, and having the permissions of the user, I could indeed post on the user's friends walls via the php api:
$facebook->api('/[FRIEND_ID]/feed', 'post', array(
'message' => 'test message',
'link' => 'http://google.com',
'name' => 'test name',
'caption' => 'test caption',
'description' => 'test long description',
));
Solution 3
The publish_stream permission only allows you to publish content on that particular users wall - you cannot post on the wall of all his friends.
Think about it this way - say you have not authorized an application to post anything on your facebook wall but just because one of your friends has given access to his wall - it automatically does not give the application access to publish on the wall of all his friends.
EDIT
Rahul, I tried yesterday night to login as myself and post a message on the wall of one of my friends through my app and surprisingly it worked. I was under the wrong impression that you could not do that. My apologies.
But I'm still not able to figure this out. Let me explain
1) I have my real facebook lets call it abc and a test facebook account xyz which I've added as my friend to abc 2) I login into my app using my abc faceboook account and publish a message on the wall of my friend xyz 3) Now I login to facebook.com as abc and it shows on my news feed the message that I published on xyz's wall. When I click on xyz's profile - the message shows up on his wall too. So far so good 4) Now I log out of facebook.com as abc and log back in as xyz. But now I dont see the message that was posted through the app on the wall of xyz.
I dont know if there is any kind of delay but I've waited 30 mins but still its not there. But it continues to show when I log in as abc.
I hope you understand what I'm trying to convey here. I've used the same piece of code like yours - so can you try the above scenarios and see if you experience something similar
Thanks
Ram Kumar
Updated on June 04, 2022Comments
-
Ram Kumar almost 2 years
Posting a message on friend's wall, graph API. i have the publish_stream extended permission of the user, who is using the application.
the code workds if i want to post sth on my wall.
is there any method to post on wall or send message to all the friends of a particular user??
please help thanks!!
following is the code, but it is not working.
$friends = $facebook->api('/me/friends'); foreach($friends['data'] as $friend){ $friendsUserId = $friend['id']; echo $friendsUserId . "</br>"; $result = $facebook->api('/$friendsUserId/feed', 'POST', array( message' => 'Test Message' )); print_r($result); }
-
Ram Kumar about 13 yearscool, but how do i publish on wall of user's friends?? was the main question.
-
Gublooo about 13 years@rahul - you cannot post on the wall of a user's friends - like I explained - the user has given you permission to publish on his wall - each user has to give explicit permission - so its not possible for you to publish on the wall of a user's friends - This is as far as my knowledge is concerned - I will dig further today and get back to see if its possible
-
Gublooo about 13 years@rahul - I have updated my answer with the little testing I did yesterday. So i retract my earlier comment of saying its not possible.
-
Ram Kumar about 13 yearsthere are spam apps which do that i was a victim of one. there would be some way of doing that. dig and let me know. thanks for your effort.
-
CBroe almost 12 years“said friend must have also gone through the 'Permissions' dialogue at some point.” – what gave you that idea?
-
Underdog over 10 yearsthis wont work anymore. see facebook blog for reference. developers.facebook.com/blog/post/2012/10/10/…