我正在处理Google日历与我的应用程序同步。 我使用最新的google-api-php-client批量请求Google日历php API
现在我想更新我所有的事件,所以我想使用批处理操作。 PHP客户端API的示例代码:
$client = new Google_Client();
$plus = new Google_PlusService($client);
$client->setUseBatch(true);
$batch = new Google_BatchRequest();
$batch->add($plus->people->get(''), 'key1');
$batch->add($plus->people->get('me'), 'key2');
$result = $batch->execute();
所以,当我“翻译”它的日历API,我成了下面的代码: $客户端=新Google_Client(); $ this-> service = new Google_CalendarService($ client);
$client->setUseBatch(true);
// Make new batch and fill it with 2 events
$batch = new Google_BatchRequest();
$gEvent1 = new Google_event();
$gEvent1->setSummary("Event 1");
$gEvent2 = new Google_event();
$gEvent2->setSummary("Event 2");
$batch->add($this->service->events->insert('primary', $gEvent1));
$batch->add($this->service->events->insert('primary', $gEvent2));
$result = $batch->execute();
但是当我运行此代码,我得到这个错误:
Catchable fatal error: Argument 1 passed to Google_BatchRequest::add()
must be an instance of Google_HttpRequest, instance of Google_Event given
而且我不认为 “$加功能>以人为>获取( '')” 是一个HttpRequest的。
有人知道我做错了什么,或者我应该用什么方法/对象来添加批处理? 或日历的批处理操作的正确用法是什么?
在此先感谢!