0

首先我要弄清楚几件事

1.这不是垃圾群成员正常点赞和评论

2.只有我使用这个应用程序

  1. 我有权在群组和页面上发帖 (manage_pages,Publish_stream)

在其详细信息和代码下方

我为发布创建了一个循环,以便我下面的代码从我的数据库中加载组 ID 数据,然后在该组上发布,但问题是,如果发生任何错误,脚本将停止工作,即使发生错误,我也想继续

所以问题如何继续在其他群组墙上发帖,即使发生错误?意味着我不在乎我的帖子是否不在显示错误的那个组上发布,而是在其他组上发布

下面是这个的代码

//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 ;
        }       
4

1 回答 1

1

我猜是 $facebook->api 如果没有发布权限或其他东西会引发异常。如果是这样,那就很容易了。只需用 try - catch 语句包装调用:

try {
     $response = $facebook->api('/' . $group_id . '/feed','POST',$WallPost);
}
catch(Exception $e) {
    //An exception occurred but don't do anything
}
于 2012-04-09T12:37:36.290 回答