Получена ошибка (400). Проверка предварительного условия не удалась.
google/apiclient: ^1.1
я вижу статью, где $client->setSubject("User@mydomain.com"); необходим, но в этом пакете нет этого метода.
Код: Выделить всё
// Set up Google API client
$client = new Google_Client();
// Load service account JSON file and set up credentials
$credentials = $client->loadServiceAccountJson(config('const.GOOGLE_APPLICATION_CREDENTIALS'), array('https://www.googleapis.com/auth/gmail.readonly'));
$client->setAssertionCredentials($credentials);
// Check if access token is expired and refresh if necessary
if ($client->getAuth()->isAccessTokenExpired()) {
$client->getAuth()->refreshTokenWithAssertion();
}
// Initialize Gmail Service
$gmailService = new Google_Service_Gmail($client);
// Fetch emails
$messages = $gmailService->users_messages->listUsersMessages('me', ['q' => 'has:attachment']);
dd("done", $messages); // Output the result for debugging purposes
Источник: https://stackoverflow.com/questions/781 ... php-script
Мобильная версия