javascript - Get all messages by label from gmail account -


I want to make a reporting tool based on export from the google gmail API. So the main thing I want to do is to get all the inbox messages from my account through labels in Gmail, and display it in custom custom form in my custom e-mail document. I want to do it with php or javascript I did some research in Google API, but did not understand how to start working, where?

I think it would be nice if JSON data can be obtained from this URL

How can I, which GS Libs need to include me, how to work with Google AP? I have never worked with it before, can someone show me some simple full examples?

Here is a Google API JavaScript client loading, loading Gmail APIs, and labels and inbox messages Showing the way to call two API methods for the list of For every API call, there are a lot of JavaScript code snippets in the GMI LAPI docs so that you can add whatever code snippet you want to get the structure of the code given below to whatever you want.

  and lieutenant ;; DOCTYPE html & gt; & Lt; Html & gt; & Lt; Top & gt; & Lt; Meta charset = 'UTF-8' / & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt ;! - Add a button to the user to click to start the Oath sequence - & gt; & Lt; Button ID = "Authorized-Button" style = "Visibility: hidden" & gt; Authorize & lt; / Button & gt; & Lt; Div id = "content" & gt; & Lt; / Div & gt; & Lt; P & gt; Test Gmail API & Lt; / P & gt; & Lt; Script type = "text / javascript" & gt; // Enter the client ID for the web application from Google Developer Console. // In your Developer Console project, add a JavaScript root that matches the domain // where you want to run the script Var client id = 'YOUR_CLIENT_ID_HERE'; // To enter one or more authentication scope, see the documentation for the API. Var scope = 'https://www.googleapis.com/auth/gmail.readonly'; // Use a button to handle authentication for the first time function handleclip () {window.setTimeout (checkout, 1); } Function checkAuth () {gapi.auth.authorize ({client_id: clientId, Scope: Scope, Instant: Truth}, HandleSurst); } Function handout (authResult) {var authorizeButton = document.getElementById ('authorize-button'); If (authResult & amp;; authResult.error) {authorizeButton.style.visibility = 'hidden'; MakeApiCall (); } And {authorizeButton.style.visibility = ''; AuthorizeButton.onclick = handleAuthClick; }} Function HandleOther Click (Event) {gapi.auth.authorize ({client_id: Client ID, Region: Scope, Instant: Incorrect}, HandralResult); return false; } // Load the API and call the API. Display results on screen function make apple () {gapi.client.load ('gmail', 'v1', function () {listLabels (); list message ();}); } / ** * Get all the labels in the authenticated user's mailbox * / function list label () {var userId = "me"; Var request = gapi.client.gmail.users.labels.list ({'userId': userId}); Request.execute (function) {var labels = resp.labels; var output = ("query" returned <+ labels. + Lamps + "labels: 
); (Var i = 0; I & lt; labels.length; i ++) {output = = label [i] .name + "& lt; br & gt;";} document.getElementById ("content") .interHTML + = output;}); } / ** * Get all message IDs in the authenticated user's inbox * / function list message () {var userId = "me"; Var request = gapi.client.gmail.users.messages.list ({'userId': userId}); Request.execute (function (resp) {var message = resp.messages; var output = "
query returned" + messages.length + "for messages: br & gt;" (Var i = 0; i & lt; Message.length; i ++) {output = = message [i] .ID + "& lt; br & gt;";} document.getElementById ("content"). InnerHTML + = Output;}); } & Lt; / Script & gt; & Lt; Script src = "https://apis.google.com/js/client.js?onload=handleClientLoad" & gt; & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt;


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -