开发者

Posting to a friends wall on facebook privately using graph api

I wanted to post a feed to a friends wall from my app and set it as private, which is viewable to the logged in user and the friend. I want to do this using the new Graph api, I saw that if I set the "to" parameter in the feed post, it will be posted to the users friend wall.

I found a code here: http://forum.developers.facebook.net/viewtopic.php?id=56458 (Posted by VovaOnline开发者_运维百科) (link is dead, as facebook has taken down the forum)

$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' => array(
                'description' => 'Vladimir Sergeevich',
                'value'   => 'CUSTOM',
                'friends' => 'SOME_FRIENDS',
                'allow'   => '100001338940933'
            )
         ));

I am setting the post type as "link". Can anyone tell me what is wrong in this code. One thing I know that "from" field has to be "to" and it has to be passed in a "data" variable. I am not sure how to do it. Can any one help me?


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)
     ));


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜