首先,我得到我的朋友列表,选择 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);
});
});
}