开发者

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. I ask only for the publish_to_stream permission but it seems to work properly. I have read som开发者_开发知识库e 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 ?

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 {
    $post_id = $facebook->api("/$USER_ID/feed", "post", $currentPost);
} catch(FacebookApiException $e) {
    //error sending the post
}

That was the reason why the script stops.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜