Reputation: 21
First I get my friend list, select 5 friends and try to tag them in a status update. However, nothing posts. i'm sure the error is here { tags: tags } or tags += + friend["id"] + ","; I'm trying to separate each ID wit ha comma and put the whole thing under the tags variable
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);
});
});
}
Upvotes: 0
Views: 993
Reputation: 336
In order for your problem to be resolved you should add all parameters to the POST body.
Example:
FB.api("/me/feed", "post", { place: "132738745815", tags: tags, message: "look here", access_token: "<?php echo $tkn;?>" }, function(response) {
commenter(commentsLeft);
});
Good luck!
Upvotes: 1