【问题标题】:facebook multiple publish to wallfacebook多次发布到墙上
【发布时间】:2011-08-06 17:54:13
【问题描述】:

我使用 js sdk 通过我在 facebook 中创建的应用程序从我的网站向朋友墙发布消息。当我发布到单墙时,上面的代码运行良好。我想将同一消息同时发布到多个墙上并且不出现弹出窗口或对话框的问题。我知道它必须通过循环来完成,但不能让它工作。

我的代码是

 var publish =
            {
                method: 'stream.publish',
                // display: 'popup',


                attachment: 
                {
                    name: 'name' ,
                    caption: 'www.caption.com'  ,
                    description: ('description'),
    href: 'url',
                    media: [
                  {
                    type: 'image',
           href: 'url',
                    src: 'url'
                  }
                ]                   
                }
            };

         publish.target_id =id1;
         FB.ui(publish);
         publish.target_id = id2;
         FB.ui(publish);

            return false;

        }

我们将不胜感激。

谢谢

【问题讨论】:

    标签: php javascript facebook facebook-graph-api


    【解决方案1】:

    由于:http://developers.facebook.com/policy/

    5. You must not provide users with the option to publish more than one Stream story at a time.
    

    您应该避免同时在多个墙上发布相同的消息。

    编辑

    但如果你真的不想这样做: 您不应该使用用于 Facebook Dialogs 的 Fb.ui()。

    您可以使用:

    var body = 'Reading JS SDK documentation';
    FB.api('/me/feed', 'post', { message: body }, function(response) {
      if (!response || response.error) {
        alert('Error occured');
      } else {
        alert('Post ID: ' + response.id);
      }
    });
    

    因此,您只需循环您的 UserID,并将“me”替换为 user_id。

    【讨论】:

    • 值得注意的是,如果 Facebook 的应用团队发现您这样做,他们会先下架您的应用,然后再提出问题,因此请考虑是否真的值得。
    【解决方案2】:

    最后我用这段代码让它工作了:

    function  doitonfacebook(){
    
    var receivers = document.getElementById("selected-friends").innerHTML; 
    
    var temp = new Array();
    
    temp = receivers.split(',');
    
    var count =temp.length;
    
     for (var i = 0; i < count; i++) {
    
     var publish = {
    
         method: 'stream.publish',
         message: 'test',
         picture : 'http://www.takwing.idv.hk/facebook/demoapp_jssdk/img/logo.gif',
         link : 'http://www.test.com',
         name: 'test',
         caption: 'Caption of the Post',
         description: 'testttttt',
         actions : { name : 'testing', link : 'http://www.takwing.idv.hk/tech/fb_dev/index.php'}
       };
    
    FB.api('/'+temp[i]+'/feed', 'post',publish, function(response) {
      if (!response || response.error) {
        alert('Error occured');
      } else {
        alert('success publishing: ' );
      }
    });
    
    
            }}
    

    感谢回复

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-11-07
      • 1970-01-01
      • 1970-01-01
      • 2011-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多