Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(PureBasic) Get a List of Message IDs in GMail User's MailboxDemonstrates 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. For more information, see https://developers.google.com/gmail/api/v1/reference/users/messages/list
IncludeFile "CkHttpResponse.pb" IncludeFile "CkHttp.pb" IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkHttp::setCkAuthToken(http, "ACCESS_TOKEN") CkHttp::setCkAccept(http, "application/json") resp.i = CkHttp::ckQuickRequest(http,"GET","https://www.googleapis.com/gmail/v1/users/userId/messages") If CkHttp::ckLastMethodSuccess(http) <> 1 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) ProcedureReturn EndIf Debug "Response Status Code: " + Str(CkHttpResponse::ckStatusCode(resp)) jsonResponse.i = CkJsonObject::ckCreate() If jsonResponse.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoad(jsonResponse,CkHttpResponse::ckBodyStr(resp)) CkJsonObject::setCkEmitCompact(jsonResponse, 0) Debug CkJsonObject::ckEmit(jsonResponse) If CkHttpResponse::ckStatusCode(resp) <> 200 Debug "Failed." CkHttpResponse::ckDispose(resp) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonResponse) ProcedureReturn EndIf CkHttpResponse::ckDispose(resp) ; { ; "messages": [ ; users.messages Resource ; ], ; "nextPageToken": string, ; "resultSizeEstimate": unsigned integer ; } id.s threadId.s resultSizeEstimate.i = CkJsonObject::ckIntOf(jsonResponse,"resultSizeEstimate") i.i = 0 count_i.i = CkJsonObject::ckSizeOfArray(jsonResponse,"messages") While i < count_i CkJsonObject::setCkI(jsonResponse, i) id = CkJsonObject::ckStringOf(jsonResponse,"messages[i].id") threadId = CkJsonObject::ckStringOf(jsonResponse,"messages[i].threadId") i = i + 1 Wend CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonResponse) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.