google client php get inbox messages

Solutions on MaxInterview for google client php get inbox messages by the best coders in the world

showing results for - "google client php get inbox messages"
Silvia
23 Nov 2020
1        $optParams = [];
2        $optParams['maxResults'] = 5; // Return Only 5 Messages
3        $optParams['labelIds'] = 'INBOX'; // Only show messages in Inbox
4        $messages = $service->users_messages->listUsersMessages('me',$optParams);
5        $list = $messages->getMessages();
6        $messageId = $list[0]->getId(); // Grab first Message
7
8
9        $optParamsGet = [];
10        $optParamsGet['format'] = 'full'; // Display message in payload
11        $message = $service->users_messages->get('me',$messageId,$optParamsGet);
12        $messagePayload = $message->getPayload();
13        $headers = $message->getPayload()->getHeaders();
14        $parts = $message->getPayload()->getParts();
15
16        $body = $parts[0]['body'];
17        $rawData = $body->data;
18        $sanitizedData = strtr($rawData,'-_', '+/');
19        $decodedMessage = base64_decode($sanitizedData);
20
21        var_dump($decodedMessage);
22