我對Facebook PHP SDK超級新手。我無法理解下面的堆棧跟蹤;我應該在哪裏尋找錯誤?麻煩理解Facebook Uncaught異常
Facebook計劃的帖子正在成功處理,但是,此錯誤會導致不良的用戶體驗,但是,我的程序中的其他所有內容都正常工作。看起來它可能試圖處理那些不存在的東西。正在執行
的最後一行代碼(我知道是因爲排定發表的文章在我的Facebook測試帳號顯示)是:
$responses = $fb->sendBatchRequest(($batch), $this->session->userdata('fb_access_token'));
$一批被定義爲:
foreach($esdarr as $key => $event_start_datetime){$sched_time = strtotime($event_start_datetime)- 18000;
$event_end_datetime = $eedarr[$key];
$requestScheduleEvent = $fb->post('/'.$band_page_id.'/feed', ['message' => $band_name.' is playing today at '.$venue_name.' '.date('(l), g:ia', strtotime($event_start_datetime)), 'published'=>false, 'scheduled_publish_time'=>$sched_time], $pageToken);
$batch[$key]=$requestScheduleEvent;
}
這是全部在具有公共函數add()的CI控制器(event.php)中。然後,我得到這個錯誤:如果我改變線#85 FacebookBatchRequest.php的
Fatal error: Uncaught exception 'InvalidArgumentException' with message 'Argument for add() must be of type array or FacebookRequest.' in /home/my_user/public_html/development/application/vendor/facebook/php-sdk-v4/src/Facebook/FacebookBatchRequest.php:85 Stack trace:
#0 /home/my_user/public_html/development/application/vendor/facebook/php-sdk-v4/src/Facebook/FacebookBatchRequest.php(78): Facebook\FacebookBatchRequest->add(Object(Facebook\FacebookResponse), 0)
#1 /home/my_user/public_html/development/application/vendor/facebook/php-sdk-v4/src/Facebook/FacebookBatchRequest.php(61): Facebook\FacebookBatchRequest->add(Array)
#2 /home/my_user/public_html/development/application/vendor/facebook/php-sdk-v4/src/Facebook/Facebook.php(492): Facebook\FacebookBatchRequest->__construct(Object(Facebook\FacebookApp), Array, 'EAAYzEGW0ZAsoBA...', 'v2.7')
#3 /home/my_user/public_html/development/application/controllers/user/event.php(777): Facebook\Facebook->sendBatchRequest(Array, 'EAAYzEGW0ZAsoBA...')
#4 [internal function]: Event->add in /home/my_user/public_html/development/application/vendor/facebook/php-sdk-v4/src/Facebook/FacebookBatchRequest.php on line 85
如下(即,頁面重定向到CI結構中正確的URL),一切似乎都很好地工作:
public function add($request, $name = null)
{
if (is_array($request)) {
foreach ($request as $key => $req) {
$this->add($req, $key);
}
return $this;
}
if (!$request instanceof FacebookRequest) {
***redirect('user/event');***
throw new \InvalidArgumentException('Argument for add() must be of type array or FacebookRequest.');
}
$this->addFallbackDefaults($request);
$requestToAdd = [
'name' => $name,
'request' => $request,
];
當然,這是一個很好的解決方法。所以,我想知道爲什麼錯誤首先被拋出。