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
(AutoIt) 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
; This example requires the Chilkat API to have been previously unlocked. ; See Global Unlock Sample for sample code. $oHttp = ObjCreate("Chilkat.Http") ; Use your previously obtained access token here: Get Outlook Contacts OAuth2 Access Token (Azure AD v2.0 Endpoint). $oJsonToken = ObjCreate("Chilkat.JsonObject") Local $bSuccess = $oJsonToken.LoadFile("qa_data/tokens/outlookContacts.json") If ($bSuccess = False) Then ConsoleWrite($oJsonToken.LastErrorText & @CRLF) Exit EndIf $oHttp.AuthToken = $oJsonToken.StringOf("access_token") ; Send the following GET: ; GET https://graph.microsoft.com/v1.0/me/contacts $oSbJson = ObjCreate("Chilkat.StringBuilder") $bSuccess = $oHttp.QuickGetSb("https://graph.microsoft.com/v1.0/me/contacts",$oSbJson) If ($bSuccess = False) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf Local $iStatusCode = $oHttp.LastStatus ConsoleWrite("Response status code = " & $iStatusCode & @CRLF) If ($iStatusCode <> 200) Then ConsoleWrite($oSbJson.GetAsString() & @CRLF) ConsoleWrite("Failed." & @CRLF) Exit EndIf $oJResp = ObjCreate("Chilkat.JsonObject") $oJResp.LoadSb($oSbJson) $oJResp.EmitCompact = False ConsoleWrite($oJResp.Emit() & @CRLF) ; 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": {} ; }, ; ... ; ] ; } Local $sOdata_etag Local $sId Local $sCreatedDateTime Local $sLastModifiedDateTime Local $sChangeKey Local $sParentFolderId Local $sBirthday Local $sFileAs Local $sDisplayName Local $sGivenName Local $sInitials Local $sMiddleName Local $sNickName Local $surname Local $sTitle Local $sYomiGivenName Local $sYomiSurname Local $sYomiCompanyName Local $sGeneration Local $sJobTitle Local $sCompanyName Local $sDepartment Local $sOfficeLocation Local $sProfession Local $sBusinessHomePage Local $sAssistantName Local $sManager Local $sMobilePhone Local $spouseName Local $sPersonalNotes Local $iJ Local $iCount_j Local $strVal Local $sName Local $sAddress Local $sOdata_context = $oJResp.StringOf("""@odata.context""") Local $i = 0 Local $iCount_i = $oJResp.SizeOfArray("value") While $i < $iCount_i $oJResp.I = $i $sOdata_etag = $oJResp.StringOf("value[i].""@odata.etag""") $sId = $oJResp.StringOf("value[i].id") $sCreatedDateTime = $oJResp.StringOf("value[i].createdDateTime") $sLastModifiedDateTime = $oJResp.StringOf("value[i].lastModifiedDateTime") $sChangeKey = $oJResp.StringOf("value[i].changeKey") $sParentFolderId = $oJResp.StringOf("value[i].parentFolderId") $sBirthday = $oJResp.StringOf("value[i].birthday") $sFileAs = $oJResp.StringOf("value[i].fileAs") $sDisplayName = $oJResp.StringOf("value[i].displayName") $sGivenName = $oJResp.StringOf("value[i].givenName") $sInitials = $oJResp.StringOf("value[i].initials") $sMiddleName = $oJResp.StringOf("value[i].middleName") $sNickName = $oJResp.StringOf("value[i].nickName") $surname = $oJResp.StringOf("value[i].surname") $sTitle = $oJResp.StringOf("value[i].title") $sYomiGivenName = $oJResp.StringOf("value[i].yomiGivenName") $sYomiSurname = $oJResp.StringOf("value[i].yomiSurname") $sYomiCompanyName = $oJResp.StringOf("value[i].yomiCompanyName") $sGeneration = $oJResp.StringOf("value[i].generation") $sJobTitle = $oJResp.StringOf("value[i].jobTitle") $sCompanyName = $oJResp.StringOf("value[i].companyName") $sDepartment = $oJResp.StringOf("value[i].department") $sOfficeLocation = $oJResp.StringOf("value[i].officeLocation") $sProfession = $oJResp.StringOf("value[i].profession") $sBusinessHomePage = $oJResp.StringOf("value[i].businessHomePage") $sAssistantName = $oJResp.StringOf("value[i].assistantName") $sManager = $oJResp.StringOf("value[i].manager") $sMobilePhone = $oJResp.StringOf("value[i].mobilePhone") $spouseName = $oJResp.StringOf("value[i].spouseName") $sPersonalNotes = $oJResp.StringOf("value[i].personalNotes") $iJ = 0 $iCount_j = $oJResp.SizeOfArray("value[i].categories") While $iJ < $iCount_j $oJResp.J = $iJ $iJ = $iJ + 1 Wend $iJ = 0 $iCount_j = $oJResp.SizeOfArray("value[i].imAddresses") While $iJ < $iCount_j $oJResp.J = $iJ $iJ = $iJ + 1 Wend $iJ = 0 $iCount_j = $oJResp.SizeOfArray("value[i].homePhones") While $iJ < $iCount_j $oJResp.J = $iJ $iJ = $iJ + 1 Wend $iJ = 0 $iCount_j = $oJResp.SizeOfArray("value[i].businessPhones") While $iJ < $iCount_j $oJResp.J = $iJ $strVal = $oJResp.StringOf("value[i].businessPhones[j]") $iJ = $iJ + 1 Wend $iJ = 0 $iCount_j = $oJResp.SizeOfArray("value[i].children") While $iJ < $iCount_j $oJResp.J = $iJ $iJ = $iJ + 1 Wend $iJ = 0 $iCount_j = $oJResp.SizeOfArray("value[i].emailAddresses") While $iJ < $iCount_j $oJResp.J = $iJ $sName = $oJResp.StringOf("value[i].emailAddresses[j].name") $sAddress = $oJResp.StringOf("value[i].emailAddresses[j].address") $iJ = $iJ + 1 Wend $i = $i + 1 Wend |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.