如何继续在facebook上发帖甚至出现错误?

时间:2012-04-09 12:05:18

标签: php facebook facebook-graph-api

首先,我必须清除一些事情

1.这不是垃圾邮件组成员喜欢和通常评论

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

  1. 我有权在群组和网页上发帖(manage_pages,Publish_stream)
  2. 低于其详细信息和代码

    我制作一个发布循环,以便我的下面的代码从我的数据库中加载组ID数据而不是在该组上发布,但问题是如果发生任何错误,脚本停止工作我想继续甚至发生错误< / p>

    所以问题如何继续发布在其他群组墙上甚至会发生错误?表示我不在乎我的帖子是否在该群组上发布,但该群组显示错误但在其他群体上发帖小组

    下面是这个

    的代码
    //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 ;
            }       
    

1 个答案:

答案 0 :(得分:1)

我猜这是$ facebook-&gt; api,如果没有发布或者某事的许可,会抛出异常。如果是这样的话很容易。用try - catch语句包装调用:

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