使用 graph api 私下发布到 Facebook 上的朋友墙

发布于 2024-10-08 02:42:50 字数 1098 浏览 2 评论 0原文

我想从我的应用程序将提要发布到朋友墙上,并将其设置为私有,登录用户和朋友都可以查看。 我想使用新的 Graph api 来做到这一点,我看到如果我在 feed 帖子中设置“to”参数,它将被发布到用户朋友墙上。

我在这里找到了一个代码: http://forum.developers.facebook.net/viewtopic.php? id=56458 (由VovaOnline发布) (链接已失效,因为 Facebook 已关闭该论坛)

$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 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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

酒中人 2024-10-15 02:42:50

您必须对隐私数组进行编码,请尝试以下操作:

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

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)
     ));
莫相离 2024-10-15 02:42:50

我认为 Facebook 目前不允许你这样做。查看关于发布的图形 API 文档:

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

它说关于隐私:

“注意:此隐私设置仅适用于当前或指定用户自己的留言墙上的帖子。对于目标留言墙上的帖子,Facebook 会忽略此设置(当用户在连接到的朋友、主页、活动、群组的留言墙上书写时)与 Facebook 上的行为一致,任何可以看到目标墙的人都可以查看所有目标帖子。”

我对此的解释是,如果您在别人的墙(提要)上发帖,那么隐私就不受您的控制。

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.

甜心 2024-10-15 02:42:50

从现在开始,由于 2013 年 2 月 6 日发生的重大更改,无法在用户的朋友墙上发帖:

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

删除通过 Graph API 向朋友墙发帖的功能我们将
删除通过图表向用户朋友墙发帖的功能
API。具体来说,针对 [user_id]/feed 的帖子,其中 [user_id] 是
与会话用户或stream.publish调用不同,其中
target_id 用户与会话用户不同,将会失败。如果你
想要允许人们发布到他们朋友的时间线,调用
提要对话框。通过用户提及标签或包含朋友的故事
动作标记将显示在朋友的时间线上(假设
朋友批准该标签)。有关详细信息,请参阅此博文。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文