Last active
March 22, 2017 09:12
-
-
Save jrdnrc/83f91c55b9374bfbb6ffa72f30557fc8 to your computer and use it in GitHub Desktop.
Retrieving a message
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php declare(strict_types = 1); | |
// assuming Google_Client is already configured, and assigned to $client | |
// $currentUser is the currently authenticated user | |
$gmail = new Google_Service_Gmail($client); | |
$googleUserId = $currentUser->getGoogleId(); | |
$response = $gmail->users_messages->listUsersMessages( | |
$googleUserId, | |
[ | |
'q' => 'your gmail search query', | |
] | |
); | |
$rawData = []; | |
foreach ($response as $messageResponse) { | |
$rawData[$messageResponse->getId()] = $gmail->users_messages->get( | |
$googleUserId, | |
$messageResponse->getId(), | |
[ | |
'format' => 'raw', | |
] | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment