devsri
devsri

Reputation: 6183

Post on friend's wall using PHP SDK for Facebook

I am trying to post on my friend's wall using PHP SDK of FB. The code publishes the post on my wall only and also not visible to others.

Here is the code:

$ret_obj = $facebook->api('/me/feed', 'POST',array(
            'link' => 'www.google.com',
            'message' => 'message','description' => "I am bond",
            'to' => array('id' => 'friend_id','name' => 'friend_name'),
            'actions' => array('name' => 'Re-share',
            'link' =>'http://apps.facebook.com/my_app/'),
            'privacy' => array('value' => 'EVERYONE')));

This code publishes on my wall rather than the friend's wall. Also the post is only visible to me and not to any one else.

Upvotes: 2

Views: 9733

Answers (3)

bkaid
bkaid

Reputation: 52063

To post on a friends wall do an HTTP POST to /friendID/feed instead of /me/feed (which will post to your wall). Also, remove the 'to' parameter.

Upvotes: 1

Wallace Hermano
Wallace Hermano

Reputation: 31

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

    //print_r($friends['data']);
    print_r("Number of friends: ". count($friends['data']));

    foreach ($friends['data'] as $key=>$friendList) {
        echo "<br/>".$key." ".$friendList['name']."<img src='https://graph.facebook.com/".$friendList['id']."/picture' width='50' height='50' title='".$friendList['name']."' />";     
    }

Upvotes: -1

Brian Roach
Brian Roach

Reputation: 76888

/me/feed

That's you.

/myFriendsNameHere/feed

That's your friend.

https://developers.facebook.com/docs/reference/api/

Specifically the first sentence under "Publishing" where it shows you exactly how to do what you're asking.

Upvotes: 5

Related Questions