使用Facebook Javascript SDK发布给用户'的朋友's墙-得到了有效的回应,但帖子没有

Using Facebook Javascript SDK to post to user's friend's wall - getting valid response but post does not appear on Facebook

本文关键字:回应 有效 SDK Javascript Facebook 给用户 使用 朋友      更新时间:2023-09-26

我正试图使用Facebook Javascript SDK发布到经过身份验证的用户朋友的墙上。我在回复中得到了一个有效的帖子ID,但帖子没有出现在Facebook上,当我使用FB Graph API资源管理器查看帖子时,它只是返回false。

我使用具有"publish_stream"权限的FB登录按钮进行身份验证,并设置了一个测试FB应用程序以获得有效的应用程序ID。我使用以下代码发布到用户朋友的墙上:

FB.api('/[USER_ID]/feed', 'post', {
    message: 'Testing the Facebook JavaScript API',
    link: 'http://developers.facebook.com'
}, function(response) {
    if (!response || response.error) {
        console.log('Error occured');
    } else {
        console.log('Post ID: ' + response.id);
        console.dir(response);
    }
});

当我把[USER_ID]换成"我"时,它就如预期的那样工作了——我可以在我的FB时间线上看到帖子。然而,当我使用我朋友的一个用户ID时,我会得到一个帖子ID响应,但该帖子不会出现在他们的订阅源上。想法?

这也是我的登录按钮:

<fb:login-button show-faces="false" width="200" scope="publish_stream,publish_actions" perms="publish_stream"></fb:login-button>

我也遇到了同样的问题。我疯狂地工作了5个小时。事实上,我认为没有问题。唯一的问题是,其他人墙上的帖子可以在几个小时后到达。

如果有人有同样的问题,至少要等几个小时,然后才能完全更改代码并变得疯狂。

你不能在朋友的墙上张贴

我通过从头开始创建一个全新的FB应用程序解决了这个问题,之后上面的代码就起了作用,这让我认为这个问题一定是在我以前的Facebook应用程序的配置中。我发现的唯一主要区别是在应用程序>设置>基础>网站>网站URL中,我输入了应用程序的域,而不是应用程序页面本身的完整路径。因此,您确实可以动态地将帖子发布到经过身份验证的用户朋友的墙上。

这里有javascript sdk和facebbok c#sdk:

function fb_publish() {
     FB.ui(
       {
         method: 'stream.publish',
         message: 'Message here.',
         attachment: {
           name: 'Name here',
           caption: 'Caption here.',
           description: (
             'description here'
           ),
           href: 'url here'
         },
         action_links: [
           { text: 'Code', href: 'action url here' }
         ],
         user_prompt_message: 'Personal message here'
       },
       function(response) {
         if (response && response.post_id) {
           alert('Post was published.');
         } else {
           alert('Post was not published.');
         }
       }
     );  
  }

var client = new FacebookClient("my_access_token");
dynamic parameters = new ExpandoObject();
parameters.message = "Check out this funny article";
parameters.link = "http://www.example.com/article.html";
parameters.picture = "http://www.example.com/article-thumbnail.jpg";
parameters.name = "Article Title";
parameters.caption = "Caption for the link";
parameters.description = "Longer description of the link";
parameters.actions = new {
    name = "View on Zombo",
    link = "http://www.zombo.com",
};
parameters.privacy = new {
    value = "ALL_FRIENDS",
};
parameters.targeting = new {
    countries = "US",
    regions = "6,53",
    locales = "6",
};
dynamic result = client.Post("me/feed", parameters);

如果有帮助,请将其标记为已回答:)