(Unicode C++) List all Labels in the User's Mailbox
List all Labels in the GMail User's Mailbox
#include <CkHttpW.h>
#include <CkStringBuilderW.h>
#include <CkJsonObjectW.h>
void ChilkatSample(void)
{
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
bool success;
CkHttpW http;
http.put_AuthToken(L"GMAIL-ACCESS-TOKEN");
const wchar_t *userId = L"me";
http.SetUrlVar(L"userId",userId);
const wchar_t *url = L"https://www.googleapis.com/gmail/v1/users/{$userId}/labels";
http.put_SessionLogFilename(L"c:/temp/qa_output/sessionLog.txt");
// Get the list of GMail labels as JSON.
CkStringBuilderW sb;
success = http.QuickGetSb(url,sb);
if (success != true) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
CkJsonObjectW json;
json.LoadSb(sb);
json.put_EmitCompact(false);
wprintf(L"%s\n",json.emit());
if (http.get_LastStatus() != 200) {
wprintf(L"Failed.\n");
return;
}
}
|