简体   繁体   English

发布给朋友墙Facebook javascript sdk

[英]post to friends wall facebook javascript sdk

i have problem about post something to friends wall..i actually want to do that without popup dialog appear ..like frictionless request ..i use following script but i realize that nothing happen with this script ..i need some instruction to do that..i don't want dialog box to appear and i have granted permission" publish_stream" for that .but i'm failed ..need your help 我在将某些内容发布到朋友墙上时遇到问题..我实际上想做到这一点而不会出现弹出对话框..像无摩擦请求..我使用以下脚本,但是我意识到此脚本没有任何反应..我需要一些指令来做到这一点..我不希望出现对话框,并且我已经为此授予了权限“ publish_stream”,但是我失败了..需要您的帮助

 ///////////////////////////////////////////////////////////////////////////
  function post_friend_wall()
  {
alert("try"); 
var user_id = document.getElementById("friendid").value;
var data = {
    name: "title of post",
    caption: "caption of post",
    description: "description of post"
};
var callback = function (response) {};
FB.api("/" + user_id + "/feed", "post", data, callback);
  if (!response || response.error) {
        // an error occured
        alert(JSON.stringify(response.error));
      } else {
        // Done
        alert('did');
      }
  }

  ///////////////////////////////////////////////////////////////////////////

Your callback will not work. 您的回叫将不起作用。 Since the request is asynchron, you cannot just access some of the values from callback. 由于请求是异步的,因此您不能仅从回调访问某些值。

var callback = function (response) {
    if (!response || response.error) {
        // an error occured
        alert(JSON.stringify(response.error));
      } else {
        // Done
        alert('did');
      }
};
FB.api("/" + user_id + "/feed", "post", data, callback);

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

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