mansoor ahamad
mansoor ahamad

Reputation: 23

How to post to user's wall without logging in, using the new Facebook API?

I have stored a Facebook user ID and a Facebook friend ID. How can I publish to the user's wall without logging into Facebook?

I have used the old Facebook API that has UID and target_id fields like this:

$param  =   array(
    'method'        =>  'stream.publish',
    'callback'      =>  '',
    'message'       =>  $row[message], 
    'attachment'    =>  json_encode($attachment), 
    'target_id'     =>  $row[friends_id],
    'uid'           =>  $row[sender_id],
    'privacy'       =>  ''
);

$result = $facebook->api($param);

Is this possible in new facebook PHP API?

$attachment = array('message' => $wall);
$facebook->api("/$target/feed/",'post', $attachment);

The application has wall posting permissions.

Upvotes: 1

Views: 2444

Answers (2)

Jesper Jonsson
Jesper Jonsson

Reputation: 184

According to the docs it's also possible to post to a users feed without the "offline_permission" when the "publish_stream" permission is granted:

Comment about "publish_stream" taken from the docs: Enables your app to post content, comments, and likes to a user's stream and to the streams of the user's friends. With this permission, you can publish content to a user's feed at any time, without requiring offline_access.

Upvotes: 2

Eddy Chan
Eddy Chan

Reputation: 1161

this is possible only if you have the access_token with offline_permission granted. if you have it, then include the token in $attachment with key "access_token"

Upvotes: 0

Related Questions