1

我一直在使用 Graph API 和 javascript facebook sdk 在用户墙上发帖。代码看起来像这样

函数图流发布(){
                显示加载器(真);

                FB.api('/me/feed', 'post',
                    {
                        消息:“示例消息”,
                        链接:'链接网址',
                        图片:'图片网址',
                        name : '应用名称',
                        描述:'测试的东西'

                },
                功能(响应){
                    显示加载器(假);

                    if (!response || response.error) {
                        alert('发生错误');
                    } 别的 {
                        alert('帖子ID:' + response.id);
                    }
                });
            }

这段代码也可以用来发布在用户时间轴上还是我需要做的其他事情?

4

2 回答 2

0

多年前,您可以使用带有用户 ID 的字段 TO,现在您不能发布到用户时间轴,但您可以使用带有 ID 的 TO 字段,用于在群组、事件或页面上发布。

于 2015-06-17T07:57:22.670 回答
0

以下代码有效。(注意最后使用的“publish_actions”权限)。

FB.login(function(response) {
    // handle the response

        if (response.status === 'connected') {// Logged into your app and Facebook.

                        FB.api('/me/feed', 'post', 
                            { 
                                message     : "Sample Message",
                                name        : 'app name',
                                description : 'Test stuff'

                            }, 
                            function(response) {

                                if (!response || response.error) {
                                    alert(response.error);
                                } else {
                                    alert('Post ID: ' + response.id);
                                }
                            });
          }


}, {scope: 'public_profile,email,publish_actions'} );
于 2017-05-21T21:04:21.410 回答