Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

posting on a friend's wall using graph API

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);
        }
like image 504
Ram Kumar Avatar asked Dec 09 '22 09:12

Ram Kumar


1 Answers

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.

like image 163
Mafia Avatar answered Dec 11 '22 23:12

Mafia