在Facebook用户墙上的每日自动帖子 [英] Daily Automatic post in facebook users wall
问题描述
我试图做一个脚本来每天向所有应用程序用户发布消息.它适用于大约10个用户,但随后突然停止.我只要求publish_to_stream权限,但它似乎正常工作.我读过一些帖子,说要在facebook api调用之间添加睡眠,但似乎不起作用.有人测试过吗?我也读过有关Facebook限制的内容吗?有人读过有关此限制的内容吗?
I'm trying to do a Script to post a message to all application users wall every day. It works for more or less 10 users but then it suddenly stops. I ask only for the publish_to_stream permission but it seems to work properly. I have read some post saying to add a sleep between facebook api calls but it doesn't seem to work. Have anyone tested this ? I have read also somthing about facebook limits ? Have anyone read something about this limits ?
我的代码很简单:
$facebook = new Facebook(array(
'appId' => 'xxxxxxxx',
'secret' => 'xxxxxxxxxxxxxx',
));
$post = array(
'message' => 'Message to user',
);
//for every user
while($row = mysql_fetch_array($res)){
$USER_ID = $row["uid"];
$post_id = $facebook->api("/$USER_ID/feed", "post", $post);
sleep(10);
}
有人能对此有所启发吗?
Can anybody put some light on this ?
提前谢谢!
推荐答案
最后,我使用try catch块解决了该问题:
Finally I solved it using a try catch block :
try {
$post_id = $facebook->api("/$USER_ID/feed", "post", $currentPost);
} catch(FacebookApiException $e) {
//error sending the post
}
这就是脚本停止的原因.
That was the reason why the script stops.
这篇关于在Facebook用户墙上的每日自动帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!