问题
I have a script that succesfully posts to my friend wall link and message, but when i turn on loop like this:
for ($i = $from; $i <= $to; $i++) {
$sendTo = $userid[$i];
echo '<p>sending user '.$i.'</p>';
if($result = $facebook->api("/$sendTo/feed/",'post', $attachment))
{
echo '<p>sended user '.$i.'</p>';
} else {
echo 'Oops something went wrong';
}}
it only posts 4 or 5 messages and then break. I suppos the problem is at facebook does not allowing many message to send in short time. How can i make some timeout function or something to post at least 100 messages? When i post only 5 messages i manage to post 100 messages 5 by 5, but i need to post 100 by 100. Can you help me please?
Thank you for your time and best regards
回答1:
Posting on multiple user's walls like this is discouraged by Facebook. If you want to send multiple users a message, they recommend you use the requests dialog.
To delay sending requests, you could add a sleep(300)
command after every 5 posts to give a 5 minute delay between postings. You'll have problems with script timeouts. Better would be to have your script create a cron job that posts 5 items at a time, and only runs every 5 minutes.
With either of these methods, you are spamming your users and you run a risk of your app getting disabled. See this Facebook Developers blog post for more info.
来源:https://stackoverflow.com/questions/13088242/facebook-application-php-post-to-friends-wall