Abdullah Adam
Abdullah Adam

Reputation: 178

How to continue posting on facebook even error is occur?

First of all i have to clear few things

1.This is not spam group members like and comment normally

2.only i use this app

  1. I have Permissions to post on groups and pages (manage_pages,Publish_stream)

Below its details and code

I make a loop for posting so that my below code loads groups ids data from my database and than post on that group but the problem is that if any error occur the script is stop working i want to continue even error is occur

so the question How to continue posting on others groups wall even error is occur? means i don't care if my post is not post on that group which shows the error but post on the other groups

below is code for this

//basically making loop so that we can post on each group which id we get from database 

    //now getting total groups ids record so that we stop the loop when loop reaches its target 

        $query3 = mysql_query("SELECT * FROM groupids");
        $num_rows = mysql_num_rows($query3);
        $increaser = 2 ;

    //now will make loop
        for ( $counter = 1; $counter <= $num_rows ; $counter += 1) {

            //at this time we just echo all groups ids than we convert it to post

            $query4 = mysql_query("SELECT * FROM groupids WHERE ID=$increaser LIMIT 1");
            $row4 = mysql_fetch_array($query4);
            $group_id = $row4["gids"];

            //for posting you simpley set here some coding who post on wall

            $response = $facebook->api('/' . $group_id . '/feed','POST',$WallPost);

            //its updates value so that we get new group id on next level of loop 
            $increaser += 1 ;
        }       

Upvotes: 0

Views: 100

Answers (1)

user1320635
user1320635

Reputation:

I guess that it's the $facebook->api that throws an exception if does not have permission to post or something. If that's the case it's easy. Just wrap the call with try - catch statement:

try {
     $response = $facebook->api('/' . $group_id . '/feed','POST',$WallPost);
}
catch(Exception $e) {
    //An exception occurred but don't do anything
}

Upvotes: 1

Related Questions