Lua
Lua
Get a List of Message IDs in GMail User's Mailbox
See more GMail REST API Examples
Demonstrates how to get a list of message IDs in a GMail mailbox. The "userId" can be either the user's email address or the special value "me" to indicate the authenticated user.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local http = chilkat.Http.new()
http.auth_token = "ACCESS_TOKEN"
http.accept = "application/json"
local resp = chilkat.HttpResponse.new()
local success = http:http_no_body("GET", "https://www.googleapis.com/gmail/v1/users/userId/messages", resp)
if not success then
print(http.last_error_text)
return
end
print("Response Status Code: " .. resp.status_code)
local jsonResponse = chilkat.JsonObject.new()
jsonResponse:load(resp.body_str)
jsonResponse.emit_compact = false
print(jsonResponse:emit())
if resp.status_code ~= 200 then
print("Failed.")
return
end
-- {
-- "messages": [
-- users.messages Resource
-- ],
-- "nextPageToken": string,
-- "resultSizeEstimate": unsigned integer
-- }
local id = ""
local threadId = ""
local resultSizeEstimate = jsonResponse:int_of("resultSizeEstimate")
local i = 0
local count_i = jsonResponse:size_of_array("messages")
while i < count_i do
jsonResponse.i = i
id = jsonResponse:string_of("messages[i].id")
threadId = jsonResponse:string_of("messages[i].threadId")
i = i + 1
end