Posting to a friends wall on facebook privately using graph api

三世轮回 提交于 2019-11-30 21:58:18

I don't think Facebook allows you to do this currently. Look at the graph API docs on Posting:

http://developers.facebook.com/docs/reference/api/post/

it says on privacy:

"Note: This privacy setting only applies to posts to the current or specified user's own Wall. Facebook ignores this setting for targeted Wall posts (when the user is writing on the Wall of a friend, Page, event, group connected to the user). Consistent with behavior on Facebook, all targeted posts are viewable by anyone who can see the target's Wall. "

I interpret this to mean that if you post on someone else's wall (feed), privacy is out of your control.

You must encode privacy array, try this:

$privacy = array(
            'description' => 'Vladimir Sergeevich',
            'value'   => 'CUSTOM',
            'friends' => 'SOME_FRIENDS',
            'allow'   => '100001338940933'
        );

$result = $facebook->api('/me/feed', 'POST', array(
        'from' => array(
            'name' => 'Vladimir Ageenko',
            'id'   => '100001308281502'
        ),
        'name'    => 'TEST NAME',
        'caption' => 'Test Caption',
        'description' => 'Test Description',
        'message' => 'This is test.',
        'privacy' => json_encode($privacy)
     ));

From now on it's not possible to post on user's friend wall due to February 6, 2013 breaking changes:

https://developers.facebook.com/roadmap/completed-changes/

Removing ability to post to friends walls via Graph API We will remove the ability to post to a user's friends' walls via the Graph API. Specifically, posts against [user_id]/feed where [user_id] is different from the session user, or stream.publish calls where the target_id user is different from the session user, will fail. If you want to allow people to post to their friends' timelines, invoke the feed dialog. Stories that include friends via user mentions tagging or action tagging will show up on the friend’s timeline (assuming the friend approves the tag). For more info, see this blog post.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!