使用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
我正试图使用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);
如果有帮助,请将其标记为已回答:)
相关文章:
- 如何有效地将游戏数据存储在URL查询字符串中
- 如何使用Node.js最有效地解析网页
- jquery代码在Mozilla中有效,但在其他浏览器上无效
- 有效形式-始终只显示1个错误[角度]
- Javascript袖珍参考,第121页:这是怎么回事;猴子补丁”;方法应该有效
- 单击仅在第二次单击后有效
- 什么'是在asp.net MVC中将本地化的resources.resx文件转换为javascript文件的有效
- 为什么自我执行匿名有效
- D3.js生成有效的SVG,但不显示任何内容
- 如何在AngularJS中有效地检查日期是否有效
- 为什么不是'我的函数在解析云代码中工作吗?当我在Angular和Express中测试时,它是有效的
- 滚动在Chrome中有效,但在Firefox或IE中无效
- 有效地获取两个区间之间的随机整数
- Rails将JavaScript对象存储到Model的有效方式
- Javascript XMLHttpRequest——只有第一个POST请求有效
- 使用条件语句,使 jquery fadeIn/fadeOut 仅在视口 >= 480px 时才有效
- 有效负载字节与实际字节不同
- 如何在three.js中有效地使用TraingleStripDrawMode
- 外部链接的Javascript文件赢得't执行,但函数有效
- 使用Facebook Javascript SDK发布给用户'的朋友's墙-得到了有效的回应,但帖子没有