0

首先,我得到我的朋友列表,选择 5 个朋友并尝试在状态更新中标记他们。但是,没有任何帖子。我确定错误在这里 { tags: tags } 或 tags += +friend["id"] + ","; 我正在尝试用逗号分隔每个 ID,并将整个内容放在 tags 变量下

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

1 回答 1

1

为了解决您的问题,您应该将所有参数添加到 POST 正文。

例子:

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

祝你好运!

于 2013-08-23T20:19:14.473 回答