Posting on a friend’s wall using the graphics API

Posting messages to a friend’s wall, a graphical API. I have extended publish_stream permission of the user who is using the application.

The code works if I want to post sth on my wall.

is there any way to post on the wall or send a message to all friends of a particular user?

please help thanks!

Below is the code, but it does not work.

$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); } 
+4
source share
5 answers

Maybe this will be the way to do it .. (Unverified, but I'm using something similar for my application.)

 $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 used by the PHP API .

+7
source

I just checked a little and, with user permissions, I could really post on the walls of the user's friends via 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', )); 
+5
source

The publish_stream permission allows you to publish content on this particular user wall - you cannot publish all your friends on the wall.

Think of it this way: say that you did not allow the application to publish anything on your facebook wall, but only because one of your friends granted access to its wall - it does not automatically give access to the application for publication on the wall of all its friends .

EDIT

Rahul, I tried last night to log in as I did and send a message on the wall of one of my friends through my application, and surprisingly it worked. I had the wrong impression that you could not do this. My apologies.

But I still can't figure it 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 wall.  When I click on xyz 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 do not know if there is any delay, but I waited 30 minutes, but still it was not there. But it continues to be displayed at login as abc.

Hope you understand what I'm trying to convey here. I used the same piece of code as yours - so you can try the above scripts and see if you have something like that

thanks

+3
source

The answer to Gubloo is close.

Posting to a friend’s wall is quite possible, but with one caveat, he said that at some point he said that the friend also went through the ā€œPermissionsā€ dialogue. This means that users of your application will be able to send messages to the wall of other users of your application.

I am going to give you the iPhone code because I don’t know php and think you get the gist. Just replace ā€œmeā€ with the UID of what you are trying to send, whether it be a Friend page or profile.

[_facebook requestWithGraphPath:@"/me/feed" andParams:params andHttpMethod:@"POST" andDelegate:self];

I’m really interested to know if this will give the user the opportunity to publish on the wall anyone who uses the application, and not just his friends.

0
source

$ friends = $ facebook-> api ('/ me / friends');

 foreach($friends['data'] as $friend) { $facebook->api('/$friend['id']/feed', 'post', array( 'message' => 'just a test message', 'link' => 'sample link.com', 'name' => 'just a test name', 'caption' => 'just a test caption', 'description' => 'just a test description', )); 

} The code works for me tooooo Thanks for the message

0
source

Source: https://habr.com/ru/post/1345929/


All Articles