Nenad
Nenad

Reputation: 982

Facebook Graph API Post to friends wall

is it possible to post a message on some other user's wall as currently logged user? I'm able to post a message but it appears like that the other user has sent it, not me.

It was possible with old API (via stream.publish method) but I'm unable to duplicate that functionality with the new API.

Thanks in advance!

Upvotes: 3

Views: 15083

Answers (5)

Jeff Wooden
Jeff Wooden

Reputation: 5479

Once you have an active user session/cookie, you can post to a friends wall like so:

Javascript SDK

FB.api('/FRIENDSUSERID/feed', 'post', { message: message }, function(response) {
    if (!response || response.error) {
        alert('Error occured');
    } else {
        alert('Post ID: ' + response.id);
    }
});

Replace the FRIENDSUSERID with the user id of the friend.

PHP SDK 3.1.1

$publishStream = $facebook->api("/$user/feed", 'post', array(
     'message' => "Your Message", 
     'link'    => 'http://example.com',
     'picture' => '',
     'name'    => 'App Name',
     'description'=> 'App description'
));

Just replace the $user variable with the user id of your friend.

I've put together a tutorial that shows how to do this among other things, its worth checking out: http://www.epixseo.com/index.php/facebook-php-3-3-1-and-javascript-sdk-graph-api-tutorial/

Upvotes: 0

Anders Rabo Thorbeck
Anders Rabo Thorbeck

Reputation: 1206

You can do something like this using their JavaScript SDK:

var user_id = "123456789";
var data = {
    name: "title of post",
    caption: "caption of post",
    description: "description of post"
};
var callback = function (response) {};
FB.api("/" + user_id + "/feed", "post", data, callback);

This will send a message with the data provided from the user currently logged in, to the user with the user_id specified.

In order to be allowed to post, you need to publish_stream permission, which you can request dynamically, by calling

FB.login(null,{perms: 'publish_stream'});

Upvotes: 5

nikhil
nikhil

Reputation: 1

I used this single line of code to post on the friend's wall with friendID as the id of the friend to which I want to post $attachment is the array with msg.

$result = $facebook->api($friendID.'/feed/','post',$attachment);

hope this would help..

Upvotes: 0

Bill Berlington
Bill Berlington

Reputation: 2414

Yes.. Its possible to post as a feed to the users wall...

JsonObject resul = facebookClient.Post("/me/feed", parameters) as JsonObject;

See the complete code here Post To Feed

Upvotes: 0

Rufinus
Rufinus

Reputation: 30741

see http://developers.facebook.com/docs/reference/dialogs/feed/

you have to use from / to params.

Upvotes: 0

Related Questions