Sample code for 30+ languages & platforms
AutoIt

List all Labels in the User's Mailbox

See more GMail REST API Examples

List all Labels in the GMail User's Mailbox

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oHttp = ObjCreate("Chilkat.Http")
$oHttp.AuthToken = "GMAIL-ACCESS-TOKEN"

Local $sUserId = "me"
$oHttp.SetUrlVar("userId",$sUserId)

Local $sUrl = "https://www.googleapis.com/gmail/v1/users/{$userId}/labels"

$oHttp.SessionLogFilename = "c:/temp/qa_output/sessionLog.txt"

; Get the list of GMail labels as JSON.
$oSb = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oHttp.QuickGetSb($sUrl,$oSb)
If ($bSuccess <> True) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oJson = ObjCreate("Chilkat.JsonObject")
$oJson.LoadSb($oSb)
$oJson.EmitCompact = False
ConsoleWrite($oJson.Emit() & @CRLF)

If ($oHttp.LastStatus <> 200) Then
    ConsoleWrite("Failed." & @CRLF)
    Exit
EndIf