简体   繁体   English

在Facebook用户墙上的每日自动帖子

[英]Daily Automatic post in facebook users wall

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. 它适用于大约10个用户,但随后突然停止。 I ask only for the publish_to_stream permission but it seems to work properly. 我只要求publish_to_stream权限,但它似乎正常工作。 I have read some post saying to add a sleep between facebook api calls but it doesn't seem to work. 我读过一些帖子,说要在Facebook api调用之间添加睡眠,但似乎不起作用。 Have anyone tested this ? 有人测试过吗? I have read also somthing about facebook limits ? 我也读过有关Facebook限制的内容吗? Have anyone read something about this limits ? 有人读过有关此限制的内容吗?

My code is very simple : 我的代码很简单:

    $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 ? 有人可以对此有所启发吗?

Thanks in advance! 提前致谢!

Finally I solved it using a try catch block : 最后,我使用try catch块解决了它:

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. 这就是脚本停止的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM