gmail-api

How to call Gmail API using PHP and cURL?

℡╲_俬逩灬. 提交于 2019-12-08 05:45:59
问题 I have the oauth access token but my get request fails. Below is my code: $response = array(); $crl = curl_init(); $newurl = "https://www.googleapis.com/gmail/v1/users/myemail@gmail.com/messages?access_token=" . $result['access_token']; echo $newurl . "</br>"; curl_setopt($crl, CURLOPT_HTTPGET, true); curl_setopt($crl, CURLOPT_URL, $newurl); curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1); $reply = curl_exec($crl); if ( $reply ) { echo 'successfully retrieved messages</br>'; echo $reply; } else

Get Unread emails from Google API

 ̄綄美尐妖づ 提交于 2019-12-08 05:44:16
问题 I'm trying to get the count of unread email using google API, but not able. ANy help is highly appreciated. I'm not getting any error, but the count doesnt match the actual number shown in gmail. try { String serviceAccountEmail = "xxx@developer.gserviceaccount.com"; var certificate = new X509Certificate2(@"C:\Projects\xxx\xyz\API Project-xxxxx.p12", "notasecret", X509KeyStorageFlags.Exportable); ServiceAccountCredential credential = new ServiceAccountCredential( new ServiceAccountCredential

Not authorized to request the scopes - Google OAuth2 for devices

依然范特西╮ 提交于 2019-12-08 05:38:26
问题 I've recently been working on accessing the gmail API from a python script. As the script needs to run on a server, without any form of web browser, I've had to implement the OAuth for Devices flow, as detailed at https://developers.google.com/accounts/docs/OAuth2ForDevices This has gone just fine, as I've been testing with the "profile" scope, I've been getting access tokens as expected. However, to switch over to the the actual token that my script needs, as I need to be authorised to write

How to get message flags like “seen” in Gmail API

*爱你&永不变心* 提交于 2019-12-08 04:55:45
问题 I'm trying to get email messages from Gmail using the RESTful API and I don't see how can I get message flags (read / unread and etc.). Is there any way to get message flags from the Gmail using the RESTful API? Thanks. 回答1: What do you mean by "flags" and "folders"? are you used to using IMAP and referring to it in that sense? what you normally would want is to look at labels like "UNREAD". those labels are the hardcoded, system labels and are documented at: https://developers.google.com

Script to permenantly delete my emails with Google Script

孤街浪徒 提交于 2019-12-08 04:50:02
问题 How does this Gmail.Users.Messages.remove(userId, id) work? What is the ID of the email and is it the right function to permanently delete an email? In my case I want to delete all my sent emails instantly and definitely. Here's some code I took from someone, only with a different label: function myFunction() { var threads = GmailApp.search("in:sent label:Inbox"); var me = Session.getActiveUser().getEmail(); for (var i = 0; i < threads.length; i++) { Gmail.Users.Messages.remove(me, threads[i]

GMail API: Fastest way to get the oldest email in inbox

依然范特西╮ 提交于 2019-12-08 03:19:09
问题 I want to get the oldest email in GMail inbox. How can I do that with the minimum number of API calls? One way to do it could be to get the total number of emails from Users:getProfile API and then use User.messages:list API to get the last page using " pageToken " query parameter by using the formula pageToken = totalMessages/50 to get the list of messages from the last page of my inbox and then using the mid of the last message in the list to fetch the oldest email. I am just wondering if

iOS - download attachment from Gmail using messageId and attachmentId

耗尽温柔 提交于 2019-12-08 02:26:43
问题 I am following Google Gmail API documentation in my iOS project where I need to download an attachment from a mail by using it userId, messageId and id Try out from Google. Where userId is user's Email address, id is mailId (Try it.Enter only your EmailId) messageId is which we get by using an one of above id which has an attachment. This is so far the code which I am have: - (void)fetchLabels { GTLQueryGmail *query = [GTLQueryGmail queryForUsersThreadsList]; [self.service executeQuery:query

GMail API access from chrome extension? 403 Forbidden

妖精的绣舞 提交于 2019-12-07 18:50:29
问题 I have an application that accesses Google APIs out of a Chrome extension via the workflow outlined here. Chrome Extensions OAuth Tutorial The basics of the workflow are to initialize the OAuth flow var oauth = ChromeExOAuth.initBackgroundPage({ 'request_url': 'https://www.google.com/accounts/OAuthGetRequestToken', 'authorize_url': 'https://www.google.com/accounts/OAuthAuthorizeToken', 'access_url': 'https://www.google.com/accounts/OAuthGetAccessToken', 'consumer_key': '{MY_CLIENT_ID}',

how can i read a gmail subject with php api?

ⅰ亾dé卋堺 提交于 2019-12-07 17:38:34
问题 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);

Python: how to get the subject of an email from gmail API

一曲冷凌霜 提交于 2019-12-07 16:21:26
问题 Using Gmail API, how can I retrieve the subject of an email? I see it in the raw file but it's qui cumbersome to retrieve it, and I am sure there should be a way to do it directly via the API. messageraw= service.users().messages().get(userId="me", id=emails["id"], format="raw", metadataHeaders=None).execute() It is the same question as this one but it has been close even so I can't post a better answer than the one proposed. 回答1: As mentionned in this answer, the subject is in the headers