简体   繁体   English

如何发布到授权用户(具有扩展权限)的墙-Facebook JS SDK + Graph API

[英]How to post to an Authorised User (with extended permissions) wall - Facebook JS SDK + Graph API

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? 应用程序(外部网站,因此没有fbml)如何使用JS和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. 我已经与用户建立了扩展权限,并且可以使用Facebook的示例代码发布到墙上,但是脚本中的变量不会出现在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. 在这方面的任何帮助将不胜感激。

FB.ui will pop up a confirmation dialog to the user, not sure if you want that or not. FB.ui将向用户弹出一个确认对话框,不确定是否需要。 http://developers.facebook.com/docs/reference/javascript/FB.ui 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. 本页包含有关FB.api调用的文档: http : //developers.facebook.com/docs/api向下滚动到“发布”部分,请注意未指定“ body”参数。 There is a "message" parameter though. 但是,有一个“ message”参数。 The other example you're looking at is probably incorrect? 您正在查看的另一个示例可能不正确?

我让这段代码正常工作

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM