如何发布到授权用户(具有扩展权限)墙 - Facebook JS SDK +图形API
我知道这个问题已经被问过一千次了,但我还没有找到明确的答案。
应用程序(外部网站,因此没有 fbml)如何使用 JS 和 Graph API 发布到用户墙?
我已经与用户建立了扩展权限,并且可以使用 Facebook 的示例代码发布到墙上,但是脚本中的变量不会出现在 FB 上。
例如:
function publish_test(){
var body = 'Reading Connect JS documentation';
FB.api('/me/feed', 'post', { body: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response);
}
});
}
这会发布到用户墙上,但它不包含正文。对此的任何帮助将不胜感激。
I know this question has been asked a thousand time, but I have yet to come across a definitive answer.
How does an application (external website, so no fbml) post to a users wall, using JS and Graph API?
I have established extended permissions with users, and can post to walls using Facebooks sample code, however the variables within the script wont appear on FB.
For Example:
function publish_test(){
var body = 'Reading Connect JS documentation';
FB.api('/me/feed', 'post', { body: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response);
}
});
}
This posts to the users wall, however it does not contain the body. Any help on this would be gratefully appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
FB.ui 会向用户弹出一个确认对话框,不确定您是否需要。
http://developers.facebook.com/docs/reference/javascript/FB.ui
此页面有有关 FB.api 调用的文档:
http://developers.facebook.com/docs/api
向下滚动到“Publishing”部分,请注意没有指定“body”参数。不过有一个“消息”参数。您正在查看的另一个示例可能不正确?
FB.ui will pop up a confirmation dialog to the user, not sure if you want that or not.
http://developers.facebook.com/docs/reference/javascript/FB.ui
This page has documentation about the FB.api call:
http://developers.facebook.com/docs/api
Scroll down to the "Publishing" section and notice that there's no "body" parameter specified. There is a "message" parameter though. The other example you're looking at is probably incorrect?
我让这段代码正常工作
function graphStreamPublish(){
var body = document.getElementById("txtTextToPublish").value;
FB.api('/me/feed', 'post', { 消息: 正文 }, 函数(响应) {
if (!response || response.error) {
Alert('发生错误');
} 别的 {
Alert('帖子 ID:' + response.id);
}
});
}
I got this code working
function graphStreamPublish(){
var body = document.getElementById("txtTextToPublish").value;
FB.api('/me/feed', 'post', { message: body }, function(response) {
if (!response || response.error) {
alert('Error occured');
} else {
alert('Post ID: ' + response.id);
}
});
}