0

在过去的几天里,我尝试使用图形 API(Javascript)在用户的朋友墙上发布当我使用时:

FB.api('/me/feed', 'post', params, function(response) 它有效!。

但是,当我尝试使用它时:

FB.api('/' + targetID +'/feed', 'post', params, function (response) it does not work

这是我的代码

window.fbAsyncInit = function () 
  {
   FB.init({
   appId:'1**************3', 
   status:true, 
   cookie:true, 
   xfbml:true 
  });
FB.getLoginStatus(function (response) 
 {
  if (response.status === 'connected') 
   {
       var uid = response.authResponse.userID;
       var at = response.authResponse.accessToken;
       var params = {};
       params['message'] = 'message';
       params['name'] = 'name';
       params['description'] = 'description';
       params['link'] = 'link';
       params['picture'] = 'url picture';
       params['caption'] = 'caption';

       FB.api('/me/feed', 'post', params, function(response) 
       {
        if (!response || response.error) 
         {
          alert('Error occured');
         } 
        else 
         {
          alert('Published to stream!');
         }
       });  

     var targetID='1*******2';
     FB.api('/' + targetID +'/feed',  'post', params, function(response) 
      {
       if (!response || response.error) 
       {
         alert('not published! no yay');
       } 
       else 
       {
        alert('Published yay!');
       }
      }); 
    } else if (response.status === 'not_authorized') {
    // xxxxxxx
   } else {
    // the user isn't logged in to Facebook.
  }
 });
};

(function (d, debug) 
{
  var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0];
  if (d.getElementById(id)) 
   {
    return;
   }
   js = d.createElement('script');
   js.id = id;
   js.async = true;
   js.src = "https://connect.facebook.net/en_US/all" + (debug ? "/debug" : "") + ".js";
   ref.parentNode.insertBefore(js, ref);
 }(document, /*debug*/ true));

谁能帮帮我?

非常感谢!

4

0 回答 0