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++) Outlook List ContactsSee more Outlook Contact ExamplesList Outlook Contacts For more information, see https://docs.microsoft.com/en-us/graph/api/user-list-contacts?view=graph-rest-1.0&tabs=http
#include <CkHttpW.h> #include <CkJsonObjectW.h> #include <CkStringBuilderW.h> void ChilkatSample(void) { // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttpW http; // Use your previously obtained access token here: Get Outlook Contacts OAuth2 Access Token (Azure AD v2.0 Endpoint). CkJsonObjectW jsonToken; bool success = jsonToken.LoadFile(L"qa_data/tokens/outlookContacts.json"); if (success == false) { wprintf(L"%s\n",jsonToken.lastErrorText()); return; } http.put_AuthToken(jsonToken.stringOf(L"access_token")); // Send the following GET: // GET https://graph.microsoft.com/v1.0/me/contacts CkStringBuilderW sbJson; success = http.QuickGetSb(L"https://graph.microsoft.com/v1.0/me/contacts",sbJson); if (success == false) { wprintf(L"%s\n",http.lastErrorText()); return; } int statusCode = http.get_LastStatus(); wprintf(L"Response status code = %d\n",statusCode); if (statusCode != 200) { wprintf(L"%s\n",sbJson.getAsString()); wprintf(L"Failed.\n"); return; } CkJsonObjectW jResp; jResp.LoadSb(sbJson); jResp.put_EmitCompact(false); wprintf(L"%s\n",jResp.emit()); // Sample output: // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON // { // "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('4ee732c3-322e-4a6b-b729-2fd1eb5c6004')/contacts", // "value": [ // { // "@odata.etag": "W/\"EQAAABYAAABUcG0qWqkmQYqWLHQataQxAAD0iYfT\"", // "id": "AAMkADYzZWE3YmZmLWU0YzgtNGNkZC04MGE1LWFiYTFlNTRlY2QwYQBGAAAAAAAu7cUXL5YOTrdsUIw7-v8FBwBUcG0qWqkmQYqWLHQataQxAAAAAAEOAABUcG0qWqkmQYqWLHQataQxAAD0sxexAAA=", // "createdDateTime": "2021-06-29T16:32:05Z", // "lastModifiedDateTime": "2021-06-29T16:32:06Z", // "changeKey": "EQAAABYAAABUcG0qWqkmQYqWLHQataQxAAD0iYfT", // "categories": [ // ], // "parentFolderId": "AAMkADYzZWE3YmZmLWU0YzgtNGNkZC04MGE1LWFiYTFlNTRlY2QwYQAuAAAAAAAu7cUXL5YOTrdsUIw7-v8FAQBUcG0qWqkmQYqWLHQataQxAAAAAAEOAAA=", // "birthday": null, // "fileAs": "", // "displayName": "Pavel Bansky", // "givenName": "Pavel", // "initials": null, // "middleName": null, // "nickName": null, // "surname": "Bansky", // "title": null, // "yomiGivenName": null, // "yomiSurname": null, // "yomiCompanyName": null, // "generation": null, // "imAddresses": [ // ], // "jobTitle": null, // "companyName": null, // "department": null, // "officeLocation": null, // "profession": null, // "businessHomePage": null, // "assistantName": null, // "manager": null, // "homePhones": [ // ], // "mobilePhone": null, // "businessPhones": [ // "+1 732 555 0102" // ], // "spouseName": null, // "personalNotes": "", // "children": [ // ], // "emailAddresses": [ // { // "name": "Pavel Bansky", // "address": "pavelb@fabrikam.onmicrosoft.com" // } // ], // "homeAddress": {}, // "businessAddress": {}, // "otherAddress": {} // }, // ... // ] // } // Chilkat functions returning "const char *" return a pointer to temporary internal memory owned and managed by Chilkat. // See this example explaining how this memory should be used: const char * functions. const wchar_t *odata_etag = 0; const wchar_t *id = 0; const wchar_t *createdDateTime = 0; const wchar_t *lastModifiedDateTime = 0; const wchar_t *changeKey = 0; const wchar_t *parentFolderId = 0; const wchar_t *birthday = 0; const wchar_t *fileAs = 0; const wchar_t *displayName = 0; const wchar_t *givenName = 0; const wchar_t *initials = 0; const wchar_t *middleName = 0; const wchar_t *nickName = 0; const wchar_t *surname = 0; const wchar_t *title = 0; const wchar_t *yomiGivenName = 0; const wchar_t *yomiSurname = 0; const wchar_t *yomiCompanyName = 0; const wchar_t *generation = 0; const wchar_t *jobTitle = 0; const wchar_t *companyName = 0; const wchar_t *department = 0; const wchar_t *officeLocation = 0; const wchar_t *profession = 0; const wchar_t *businessHomePage = 0; const wchar_t *assistantName = 0; const wchar_t *manager = 0; const wchar_t *mobilePhone = 0; const wchar_t *spouseName = 0; const wchar_t *personalNotes = 0; int j; int count_j; const wchar_t *strVal = 0; const wchar_t *name = 0; const wchar_t *address = 0; const wchar_t *odata_context = jResp.stringOf(L"\"@odata.context\""); int i = 0; int count_i = jResp.SizeOfArray(L"value"); while (i < count_i) { jResp.put_I(i); odata_etag = jResp.stringOf(L"value[i].\"@odata.etag\""); id = jResp.stringOf(L"value[i].id"); createdDateTime = jResp.stringOf(L"value[i].createdDateTime"); lastModifiedDateTime = jResp.stringOf(L"value[i].lastModifiedDateTime"); changeKey = jResp.stringOf(L"value[i].changeKey"); parentFolderId = jResp.stringOf(L"value[i].parentFolderId"); birthday = jResp.stringOf(L"value[i].birthday"); fileAs = jResp.stringOf(L"value[i].fileAs"); displayName = jResp.stringOf(L"value[i].displayName"); givenName = jResp.stringOf(L"value[i].givenName"); initials = jResp.stringOf(L"value[i].initials"); middleName = jResp.stringOf(L"value[i].middleName"); nickName = jResp.stringOf(L"value[i].nickName"); surname = jResp.stringOf(L"value[i].surname"); title = jResp.stringOf(L"value[i].title"); yomiGivenName = jResp.stringOf(L"value[i].yomiGivenName"); yomiSurname = jResp.stringOf(L"value[i].yomiSurname"); yomiCompanyName = jResp.stringOf(L"value[i].yomiCompanyName"); generation = jResp.stringOf(L"value[i].generation"); jobTitle = jResp.stringOf(L"value[i].jobTitle"); companyName = jResp.stringOf(L"value[i].companyName"); department = jResp.stringOf(L"value[i].department"); officeLocation = jResp.stringOf(L"value[i].officeLocation"); profession = jResp.stringOf(L"value[i].profession"); businessHomePage = jResp.stringOf(L"value[i].businessHomePage"); assistantName = jResp.stringOf(L"value[i].assistantName"); manager = jResp.stringOf(L"value[i].manager"); mobilePhone = jResp.stringOf(L"value[i].mobilePhone"); spouseName = jResp.stringOf(L"value[i].spouseName"); personalNotes = jResp.stringOf(L"value[i].personalNotes"); j = 0; count_j = jResp.SizeOfArray(L"value[i].categories"); while (j < count_j) { jResp.put_J(j); j = j + 1; } j = 0; count_j = jResp.SizeOfArray(L"value[i].imAddresses"); while (j < count_j) { jResp.put_J(j); j = j + 1; } j = 0; count_j = jResp.SizeOfArray(L"value[i].homePhones"); while (j < count_j) { jResp.put_J(j); j = j + 1; } j = 0; count_j = jResp.SizeOfArray(L"value[i].businessPhones"); while (j < count_j) { jResp.put_J(j); strVal = jResp.stringOf(L"value[i].businessPhones[j]"); j = j + 1; } j = 0; count_j = jResp.SizeOfArray(L"value[i].children"); while (j < count_j) { jResp.put_J(j); j = j + 1; } j = 0; count_j = jResp.SizeOfArray(L"value[i].emailAddresses"); while (j < count_j) { jResp.put_J(j); name = jResp.stringOf(L"value[i].emailAddresses[j].name"); address = jResp.stringOf(L"value[i].emailAddresses[j].address"); j = j + 1; } i = i + 1; } } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.