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
(Objective-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
#import <CkoHttp.h> #import <CkoJsonObject.h> #import <CkoStringBuilder.h> #import <NSString.h> // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. CkoHttp *http = [[CkoHttp alloc] init]; // Use your previously obtained access token here: Get Outlook Contacts OAuth2 Access Token (Azure AD v2.0 Endpoint). CkoJsonObject *jsonToken = [[CkoJsonObject alloc] init]; BOOL success = [jsonToken LoadFile: @"qa_data/tokens/outlookContacts.json"]; if (success == NO) { NSLog(@"%@",jsonToken.LastErrorText); return; } http.AuthToken = [jsonToken StringOf: @"access_token"]; // Send the following GET: // GET https://graph.microsoft.com/v1.0/me/contacts CkoStringBuilder *sbJson = [[CkoStringBuilder alloc] init]; success = [http QuickGetSb: @"https://graph.microsoft.com/v1.0/me/contacts" sbContent: sbJson]; if (success == NO) { NSLog(@"%@",http.LastErrorText); return; } int statusCode = [http.LastStatus intValue]; NSLog(@"%@%d",@"Response status code = ",statusCode); if (statusCode != 200) { NSLog(@"%@",[sbJson GetAsString]); NSLog(@"%@",@"Failed."); return; } CkoJsonObject *jResp = [[CkoJsonObject alloc] init]; [jResp LoadSb: sbJson]; jResp.EmitCompact = NO; NSLog(@"%@",[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": {} // }, // ... // ] // } NSString *odata_etag = 0; NSString *id = 0; NSString *createdDateTime = 0; NSString *lastModifiedDateTime = 0; NSString *changeKey = 0; NSString *parentFolderId = 0; NSString *birthday = 0; NSString *fileAs = 0; NSString *displayName = 0; NSString *givenName = 0; NSString *initials = 0; NSString *middleName = 0; NSString *nickName = 0; NSString *surname = 0; NSString *title = 0; NSString *yomiGivenName = 0; NSString *yomiSurname = 0; NSString *yomiCompanyName = 0; NSString *generation = 0; NSString *jobTitle = 0; NSString *companyName = 0; NSString *department = 0; NSString *officeLocation = 0; NSString *profession = 0; NSString *businessHomePage = 0; NSString *assistantName = 0; NSString *manager = 0; NSString *mobilePhone = 0; NSString *spouseName = 0; NSString *personalNotes = 0; int j; int count_j; NSString *strVal = 0; NSString *name = 0; NSString *address = 0; NSString *odata_context = [jResp StringOf: @"\"@odata.context\""]; int i = 0; int count_i = [[jResp SizeOfArray: @"value"] intValue]; while (i < count_i) { jResp.I = [NSNumber numberWithInt: 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"] intValue]; while (j < count_j) { jResp.J = [NSNumber numberWithInt: j]; j = j + 1; } j = 0; count_j = [[jResp SizeOfArray: @"value[i].imAddresses"] intValue]; while (j < count_j) { jResp.J = [NSNumber numberWithInt: j]; j = j + 1; } j = 0; count_j = [[jResp SizeOfArray: @"value[i].homePhones"] intValue]; while (j < count_j) { jResp.J = [NSNumber numberWithInt: j]; j = j + 1; } j = 0; count_j = [[jResp SizeOfArray: @"value[i].businessPhones"] intValue]; while (j < count_j) { jResp.J = [NSNumber numberWithInt: j]; strVal = [jResp StringOf: @"value[i].businessPhones[j]"]; j = j + 1; } j = 0; count_j = [[jResp SizeOfArray: @"value[i].children"] intValue]; while (j < count_j) { jResp.J = [NSNumber numberWithInt: j]; j = j + 1; } j = 0; count_j = [[jResp SizeOfArray: @"value[i].emailAddresses"] intValue]; while (j < count_j) { jResp.J = [NSNumber numberWithInt: j]; name = [jResp StringOf: @"value[i].emailAddresses[j].name"]; address = [jResp StringOf: @"value[i].emailAddresses[j].address"]; j = j + 1; } i = i + 1; } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.