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
(PureBasic) 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
IncludeFile "CkHttp.pb" IncludeFile "CkStringBuilder.pb" IncludeFile "CkJsonObject.pb" Procedure ChilkatExample() ; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. http.i = CkHttp::ckCreate() If http.i = 0 Debug "Failed to create object." ProcedureReturn EndIf ; Use your previously obtained access token here: Get Outlook Contacts OAuth2 Access Token (Azure AD v2.0 Endpoint). jsonToken.i = CkJsonObject::ckCreate() If jsonToken.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success.i = CkJsonObject::ckLoadFile(jsonToken,"qa_data/tokens/outlookContacts.json") If success = 0 Debug CkJsonObject::ckLastErrorText(jsonToken) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) ProcedureReturn EndIf CkHttp::setCkAuthToken(http, CkJsonObject::ckStringOf(jsonToken,"access_token")) ; Send the following GET: ; GET https://graph.microsoft.com/v1.0/me/contacts sbJson.i = CkStringBuilder::ckCreate() If sbJson.i = 0 Debug "Failed to create object." ProcedureReturn EndIf success = CkHttp::ckQuickGetSb(http,"https://graph.microsoft.com/v1.0/me/contacts",sbJson) If success = 0 Debug CkHttp::ckLastErrorText(http) CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkStringBuilder::ckDispose(sbJson) ProcedureReturn EndIf statusCode.i = CkHttp::ckLastStatus(http) Debug "Response status code = " + Str(statusCode) If statusCode <> 200 Debug CkStringBuilder::ckGetAsString(sbJson) Debug "Failed." CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkStringBuilder::ckDispose(sbJson) ProcedureReturn EndIf jResp.i = CkJsonObject::ckCreate() If jResp.i = 0 Debug "Failed to create object." ProcedureReturn EndIf CkJsonObject::ckLoadSb(jResp,sbJson) CkJsonObject::setCkEmitCompact(jResp, 0) Debug CkJsonObject::ckEmit(jResp) ; 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": {} ; }, ; ... ; ] ; } odata_etag.s id.s createdDateTime.s lastModifiedDateTime.s changeKey.s parentFolderId.s birthday.s fileAs.s displayName.s givenName.s initials.s middleName.s nickName.s surname.s title.s yomiGivenName.s yomiSurname.s yomiCompanyName.s generation.s jobTitle.s companyName.s department.s officeLocation.s profession.s businessHomePage.s assistantName.s manager.s mobilePhone.s spouseName.s personalNotes.s j.i count_j.i strVal.s name.s address.s odata_context.s = CkJsonObject::ckStringOf(jResp,Chr(34) + "@odata.context" + Chr(34)) i.i = 0 count_i.i = CkJsonObject::ckSizeOfArray(jResp,"value") While i < count_i CkJsonObject::setCkI(jResp, i) odata_etag = CkJsonObject::ckStringOf(jResp,"value[i]." + Chr(34) + "@odata.etag" + Chr(34)) id = CkJsonObject::ckStringOf(jResp,"value[i].id") createdDateTime = CkJsonObject::ckStringOf(jResp,"value[i].createdDateTime") lastModifiedDateTime = CkJsonObject::ckStringOf(jResp,"value[i].lastModifiedDateTime") changeKey = CkJsonObject::ckStringOf(jResp,"value[i].changeKey") parentFolderId = CkJsonObject::ckStringOf(jResp,"value[i].parentFolderId") birthday = CkJsonObject::ckStringOf(jResp,"value[i].birthday") fileAs = CkJsonObject::ckStringOf(jResp,"value[i].fileAs") displayName = CkJsonObject::ckStringOf(jResp,"value[i].displayName") givenName = CkJsonObject::ckStringOf(jResp,"value[i].givenName") initials = CkJsonObject::ckStringOf(jResp,"value[i].initials") middleName = CkJsonObject::ckStringOf(jResp,"value[i].middleName") nickName = CkJsonObject::ckStringOf(jResp,"value[i].nickName") surname = CkJsonObject::ckStringOf(jResp,"value[i].surname") title = CkJsonObject::ckStringOf(jResp,"value[i].title") yomiGivenName = CkJsonObject::ckStringOf(jResp,"value[i].yomiGivenName") yomiSurname = CkJsonObject::ckStringOf(jResp,"value[i].yomiSurname") yomiCompanyName = CkJsonObject::ckStringOf(jResp,"value[i].yomiCompanyName") generation = CkJsonObject::ckStringOf(jResp,"value[i].generation") jobTitle = CkJsonObject::ckStringOf(jResp,"value[i].jobTitle") companyName = CkJsonObject::ckStringOf(jResp,"value[i].companyName") department = CkJsonObject::ckStringOf(jResp,"value[i].department") officeLocation = CkJsonObject::ckStringOf(jResp,"value[i].officeLocation") profession = CkJsonObject::ckStringOf(jResp,"value[i].profession") businessHomePage = CkJsonObject::ckStringOf(jResp,"value[i].businessHomePage") assistantName = CkJsonObject::ckStringOf(jResp,"value[i].assistantName") manager = CkJsonObject::ckStringOf(jResp,"value[i].manager") mobilePhone = CkJsonObject::ckStringOf(jResp,"value[i].mobilePhone") spouseName = CkJsonObject::ckStringOf(jResp,"value[i].spouseName") personalNotes = CkJsonObject::ckStringOf(jResp,"value[i].personalNotes") j = 0 count_j = CkJsonObject::ckSizeOfArray(jResp,"value[i].categories") While j < count_j CkJsonObject::setCkJ(jResp, j) j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(jResp,"value[i].imAddresses") While j < count_j CkJsonObject::setCkJ(jResp, j) j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(jResp,"value[i].homePhones") While j < count_j CkJsonObject::setCkJ(jResp, j) j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(jResp,"value[i].businessPhones") While j < count_j CkJsonObject::setCkJ(jResp, j) strVal = CkJsonObject::ckStringOf(jResp,"value[i].businessPhones[j]") j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(jResp,"value[i].children") While j < count_j CkJsonObject::setCkJ(jResp, j) j = j + 1 Wend j = 0 count_j = CkJsonObject::ckSizeOfArray(jResp,"value[i].emailAddresses") While j < count_j CkJsonObject::setCkJ(jResp, j) name = CkJsonObject::ckStringOf(jResp,"value[i].emailAddresses[j].name") address = CkJsonObject::ckStringOf(jResp,"value[i].emailAddresses[j].address") j = j + 1 Wend i = i + 1 Wend CkHttp::ckDispose(http) CkJsonObject::ckDispose(jsonToken) CkStringBuilder::ckDispose(sbJson) CkJsonObject::ckDispose(jResp) ProcedureReturn EndProcedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.