2013-08-23 160 views
0

首先,我得到我的朋友列表,選擇5個朋友,並嘗試在狀態更新中標記它們。但是,沒有帖子。我確定錯誤在這裏{tags:tags}或tags + = + friend [「id」] +「,」; 我試圖分隔每個ID機智公頃逗號,把整個事情變標記Facebook中的朋友列表api

FB.api('/me/friends?access_token=<?php echo $tkn;?>', function(response) { 
          var friends = response["data"]; 
          for(var i = 0, n = friends.length; i < n; i++) 
          { 
           var j = Math.round(Math.random() * (n - 1)); 
           var fj = friends[j]; 
           var fi = friends[i]; 
           friends[j] = fi; 
           friends[i] = fj; 
          } 
          var commentsCount = Math.min(friends.length, 5); 
          var commenter = function(commentsLeft) { 
           if(commentsLeft == 0) 
            Step2(); 
           else 
           { 
            var mentionsCount = Math.min(commentsLeft, 5); 
            commentsLeft -= mentionsCount; 

            for(i = 0; i < mentionsCount; i++) 
            { 
             var friend = friends.pop(); 
             tags += + friend["id"] + ","; 
            } 
            FB.api("/me/feed?place=132738745815&message=look%20here&access_token=<?php echo $tkn;?>", "post", { tags: tags }, function(response) { 
             commenter(commentsLeft); 
            }); 
           } 
          }; 
          commenter(commentsCount); 
         }); 
        }); 
       }        

回答

1

標籤下,爲了讓您的問題得到解決,你應該所有參數添加到POST體。

例子:

FB.api("/me/feed", "post", { place: "132738745815", tags: tags, message: "look here", access_token: "<?php echo $tkn;?>" }, function(response) { 
    commenter(commentsLeft); 
}); 

祝你好運!