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
(Unicode C) List all Labels in the User's MailboxSee more GMail REST API ExamplesList all Labels in the GMail User's Mailbox
#include <C_CkHttpW.h> #include <C_CkStringBuilderW.h> #include <C_CkJsonObjectW.h> void ChilkatSample(void) { BOOL success; HCkHttpW http; const wchar_t *userId; const wchar_t *url; HCkStringBuilderW sb; HCkJsonObjectW json; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. http = CkHttpW_Create(); CkHttpW_putAuthToken(http,L"GMAIL-ACCESS-TOKEN"); userId = L"me"; CkHttpW_SetUrlVar(http,L"userId",userId); url = L"https://www.googleapis.com/gmail/v1/users/{$userId}/labels"; CkHttpW_putSessionLogFilename(http,L"c:/temp/qa_output/sessionLog.txt"); // Get the list of GMail labels as JSON. sb = CkStringBuilderW_Create(); success = CkHttpW_QuickGetSb(http,url,sb); if (success != TRUE) { wprintf(L"%s\n",CkHttpW_lastErrorText(http)); CkHttpW_Dispose(http); CkStringBuilderW_Dispose(sb); return; } json = CkJsonObjectW_Create(); CkJsonObjectW_LoadSb(json,sb); CkJsonObjectW_putEmitCompact(json,FALSE); wprintf(L"%s\n",CkJsonObjectW_emit(json)); if (CkHttpW_getLastStatus(http) != 200) { wprintf(L"Failed.\n"); CkHttpW_Dispose(http); CkStringBuilderW_Dispose(sb); CkJsonObjectW_Dispose(json); return; } CkHttpW_Dispose(http); CkStringBuilderW_Dispose(sb); CkJsonObjectW_Dispose(json); } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.