カレンダーからGoogleカレンダーPHP APIを使用してイベントを取得しています。同じ設定を使用して別のカレンダーにアクセスする - GoogleカレンダーAPI PHP
すべてが最初のカレンダーで機能しますが、同じ設定を使用して別のカレンダー(同じGoogleアカウント)からイベントを受信しようとしています。
ログに次のエラーがあります:
PHPの致命的なエラー:/ WWW/WWW/apacheの/ドメインで:キャッチされない例外 'Google_Service_Exceptionは' メッセージ '(404)が見つかりませんでしたエラーがhttps://www.googleapis.com/calendar/v3/calendars/CALENDAR_ID.calendar.google.com/events?maxResults=999&orderBy=startTime&singleEvents=true&timeZone=Europe%2FTallinn&timeMin=2016-09-19T00%3A01%3A00Z&timeMax=2018-07-17T00%3A00%3A00Z GET呼び出し' で。 domain.ee/htdocs/wp-content/themes/THEME/booking/vendor/google/apiclient/src/Google/Http/REST.php:79
そして、ここでのコード:私はchaged(唯一の事は$calendarId
です)
require_once 'vendor/autoload.php';
$client_email = '[email protected]';
$private_key = file_get_contents('name.p12');
$scopes = array('https://www.googleapis.com/auth/calendar');
$credentials = new Google_Auth_AssertionCredentials(
$client_email,
$scopes,
$private_key
);
$client = new Google_Client();
$client->setAssertionCredentials($credentials);
if ($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion();
}
$service = new Google_Service_Calendar($client);
// Print the next 999 events on the user's calendar.
$calendarId = '[email protected]';
$optParams = array(
'maxResults' => 999,
'orderBy' => 'startTime',
'singleEvents' => TRUE,
'timeZone' => 'Europe/Tallinn',
'timeMin' => '2016-09-19T00:01:00Z',
'timeMax' => '2018-07-17T00:00:00Z',
);
$results = $service->events->listEvents($calendarId, $optParams);
Google API Explorerに同じデータを挿入すると、探しているイベントが正確に返されます。
それは、私はサービスの電子メールでカレンダーを共有するのを忘れてしまった!どうもありがとうございます! –