在facebook api中标记朋友列表

时间:2013-08-23 19:45:08

标签: ajax facebook jquery facebook-graph-api

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

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 个答案:

答案 0 :(得分:1)

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

示例:

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

相关问题