【发布时间】:2013-01-30 07:22:22
【问题描述】:
我有以下 PHP 代码:
require 'facebook.php';
$facebook = new Facebook(array(
'appId' => 'XXXX',
'secret' => 'XXXX',
));
$ids = array('1234','5678','1348','1476');
foreach ($ids as $id) {
$USER_ID = $id;
$args = array(
'message' => 'Hello from XXXXX',
'link' => 'http://www.xxxxx.com/',
'caption' => 'Visit XXXXXXX.com for Facebook API Integration.',
'picture' => 'http://www.xxxxxxx.com/busman.png'
);
$post_id = $facebook->api("/$USER_ID/feed", "post", $args);
}
效果很好,偶尔有些用户可以卸载或撤销对 facebook 应用程序的访问权以代表他/她发布,如果该用户 ID 处于循环中,则整个过程将停止在那里,下一个用户没碰过。
即使出现此致命错误,我该怎么做才能继续循环:
Fatal error: Uncaught OAuthException: (#200) The user has not authorized the application to perform this action throw in in /home/xxxxx/public_html/xxxxx/base_facebook.php on line 1254
顺便说一句,我正在为 Facebook 使用 PHP SDK。提前致谢。
【问题讨论】:
-
你应该试试:try/cacth 看看这里:php.net/manual/en/language.exceptions.php
标签: php facebook loops fatal-error continue