Im пытается создать приложение календаря с "учетной записи службы", и я скачал последнюю версию с Google-апи-PHP-клиентGoogle Calendar API - Service Error Account
И когда я доступ serviceAccount.php я получаю следующее сообщение об ошибке:
Фатальная ошибка: Вызов неопределенной метод apiClient :: setAssertionCredentials() в /home/fmentert/public_html/reservations/google-api-php-client/examples/calendar/serviceAccount.php на линии 44
это мой файл serviceAccount.php. Я добавил идентификатор клиента, имя учетной записи службы и файл ключа. ТАКЖЕ. Я изменил сопзЬ определить() мой PHP версии 5.2.17
define('CLIENT_ID', '896988357842.apps.googleusercontent.com');
define('SERVICE_ACCOUNT_NAME', '[email protected]');
// Make sure you keep your key.p12 file in a secure location, and isn't
// readable by others.
define('KEY_FILE', 'bqwe3287e42d1c2342349f4c9769asdas55-privatekey.p12');
$client = new apiClient();
$client->setApplicationName("Google Prediction Sample");
// Set your cached access token. Remember to replace $_SESSION with a
// real database or memcached.
session_start();
if (isset($_SESSION['token'])) {
$client->setAccessToken($_SESSION['token']);
}
// Load the key in PKCS 12 format (you need to download this from the
// Google API Console when the service account was created.
$key = file_get_contents(KEY_FILE);
$client->setAssertionCredentials(new apiAssertionCredentials( // THIS IS LINE 44
SERVICE_ACCOUNT_NAME,
array('https://www.googleapis.com/auth/prediction'),
$key)
); ....
Кто-нибудь знает, что случилось?
Код, который вы отправили, пытается получить токен с неправильного URL-адреса. URL https://www.googleapis.com/auth/prediction предназначен для службы прогнозирования. Для службы календаря вам необходимо https://www.googleapis.com/auth/calendar. Поскольку ответ ниже указывает на наш, вам нужно включить файл apiClient.php и ADD в файл src/contrib/apiCalendarService.php. Прочитав ваш код, я делаю вывод, что вы скопировали код без чтения или просмотра по логике кода, чтобы сделать работу для вашей цели – IberoMedia