简体   繁体   中英

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 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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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