in witch mode a can read the email subject with php api ?
i do this code
// Get the API client and construct the service object.
$client = getClient();
$service = new Google_Service_Gmail($client);
// Print the labels in the user's account.
$user = 'me';
$results = $service->users_messages->listUsersMessages($user);
foreach($results as $mail){
$optParamsGet['format'] = 'metadata'; // Display message in payload
$message = $service->users_messages->get($user, $mail['id'],$optParamsGet);
$objMessage = $message->getPayload();
print_r($objMessage[18]['value']);
}
i find very difficult use this api with php because there isn't any documentation about the function. where i can find the comple documentation? (for example i found getPayload function because i see some example here)
thanks
If you have a look at a bare bones response you get when accessing the API with regular http-requests, I think a lot of things will be more clear.
I will list my latest message, and then get the message, and have a look at the response:
Request
Response
Request
Response
This is how a typical message will look, and all that the various libraries does is to make it easier to work with. The
headers
will reside inside of thepayload
, and it's theSubject
-header you are looking for.There is no function for getting a specific header, but it's not that hard to implement:
this works for me
....
I was working an mixed 2 or 3 examples and this is the result, in this case i need de Form metadata, change it for Subject and done.