Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(MFC) 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 <CkHttp.h> #include <CkJsonObject.h> #include <CkStringBuilder.h> void ChilkatSample(void) { CkString strOut; // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkHttp http; // Use your previously obtained access token here: Get Outlook Contacts OAuth2 Access Token (Azure AD v2.0 Endpoint). CkJsonObject jsonToken; bool success = jsonToken.LoadFile("qa_data/tokens/outlookContacts.json"); if (success == false) { strOut.append(jsonToken.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } http.put_AuthToken(jsonToken.stringOf("access_token")); // Send the following GET: // GET https://graph.microsoft.com/v1.0/me/contacts CkStringBuilder sbJson; success = http.QuickGetSb("https://graph.microsoft.com/v1.0/me/contacts",sbJson); if (success == false) { strOut.append(http.lastErrorText()); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } int statusCode = http.get_LastStatus(); strOut.append("Response status code = "); strOut.appendInt(statusCode); strOut.append("\r\n"); if (statusCode != 200) { strOut.append(sbJson.getAsString()); strOut.append("\r\n"); strOut.append("Failed."); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); return; } CkJsonObject jResp; jResp.LoadSb(sbJson); jResp.put_EmitCompact(false); strOut.append(jResp.emit()); strOut.append("\r\n"); // 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 char *odata_etag = 0; const char *id = 0; const char *createdDateTime = 0; const char *lastModifiedDateTime = 0; const char *changeKey = 0; const char *parentFolderId = 0; const char *birthday = 0; const char *fileAs = 0; const char *displayName = 0; const char *givenName = 0; const char *initials = 0; const char *middleName = 0; const char *nickName = 0; const char *surname = 0; const char *title = 0; const char *yomiGivenName = 0; const char *yomiSurname = 0; const char *yomiCompanyName = 0; const char *generation = 0; const char *jobTitle = 0; const char *companyName = 0; const char *department = 0; const char *officeLocation = 0; const char *profession = 0; const char *businessHomePage = 0; const char *assistantName = 0; const char *manager = 0; const char *mobilePhone = 0; const char *spouseName = 0; const char *personalNotes = 0; int j; int count_j; const char *strVal = 0; const char *name = 0; const char *address = 0; const char *odata_context = jResp.stringOf("\"@odata.context\""); int i = 0; int count_i = jResp.SizeOfArray("value"); while (i < count_i) { jResp.put_I(i); odata_etag = jResp.stringOf("value[i].\"@odata.etag\""); id = jResp.stringOf("value[i].id"); createdDateTime = jResp.stringOf("value[i].createdDateTime"); lastModifiedDateTime = jResp.stringOf("value[i].lastModifiedDateTime"); changeKey = jResp.stringOf("value[i].changeKey"); parentFolderId = jResp.stringOf("value[i].parentFolderId"); birthday = jResp.stringOf("value[i].birthday"); fileAs = jResp.stringOf("value[i].fileAs"); displayName = jResp.stringOf("value[i].displayName"); givenName = jResp.stringOf("value[i].givenName"); initials = jResp.stringOf("value[i].initials"); middleName = jResp.stringOf("value[i].middleName"); nickName = jResp.stringOf("value[i].nickName"); surname = jResp.stringOf("value[i].surname"); title = jResp.stringOf("value[i].title"); yomiGivenName = jResp.stringOf("value[i].yomiGivenName"); yomiSurname = jResp.stringOf("value[i].yomiSurname"); yomiCompanyName = jResp.stringOf("value[i].yomiCompanyName"); generation = jResp.stringOf("value[i].generation"); jobTitle = jResp.stringOf("value[i].jobTitle"); companyName = jResp.stringOf("value[i].companyName"); department = jResp.stringOf("value[i].department"); officeLocation = jResp.stringOf("value[i].officeLocation"); profession = jResp.stringOf("value[i].profession"); businessHomePage = jResp.stringOf("value[i].businessHomePage"); assistantName = jResp.stringOf("value[i].assistantName"); manager = jResp.stringOf("value[i].manager"); mobilePhone = jResp.stringOf("value[i].mobilePhone"); spouseName = jResp.stringOf("value[i].spouseName"); personalNotes = jResp.stringOf("value[i].personalNotes"); j = 0; count_j = jResp.SizeOfArray("value[i].categories"); while (j < count_j) { jResp.put_J(j); j = j + 1; } j = 0; count_j = jResp.SizeOfArray("value[i].imAddresses"); while (j < count_j) { jResp.put_J(j); j = j + 1; } j = 0; count_j = jResp.SizeOfArray("value[i].homePhones"); while (j < count_j) { jResp.put_J(j); j = j + 1; } j = 0; count_j = jResp.SizeOfArray("value[i].businessPhones"); while (j < count_j) { jResp.put_J(j); strVal = jResp.stringOf("value[i].businessPhones[j]"); j = j + 1; } j = 0; count_j = jResp.SizeOfArray("value[i].children"); while (j < count_j) { jResp.put_J(j); j = j + 1; } j = 0; count_j = jResp.SizeOfArray("value[i].emailAddresses"); while (j < count_j) { jResp.put_J(j); name = jResp.stringOf("value[i].emailAddresses[j].name"); address = jResp.stringOf("value[i].emailAddresses[j].address"); j = j + 1; } i = i + 1; } SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.