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
(Visual FoxPro) GetHarvest - Get Client ContactsReturns a list of your contacts. For more information, see https://help.getharvest.com/api-v2/clients-api/clients/contacts/
LOCAL loHttp LOCAL lnSuccess LOCAL loSbResponseBody LOCAL loJResp LOCAL lnRespStatusCode LOCAL lnPer_page LOCAL lnTotal_pages LOCAL lnTotal_entries LOCAL lcNext_page LOCAL lcPrevious_page LOCAL lnPage LOCAL lcLinksFirst LOCAL lcLinksNext LOCAL lcLinksPrevious LOCAL lcLinksLast LOCAL i LOCAL lnCount_i LOCAL lnId LOCAL lcTitle LOCAL lcFirst_name LOCAL lcLast_name LOCAL lcEmail LOCAL lcPhone_office LOCAL lcPhone_mobile LOCAL lcFax LOCAL lcCreated_at LOCAL lcUpdated_at LOCAL lnClientId LOCAL lcClientName * This example assumes the Chilkat API to have been previously unlocked. * See Global Unlock Sample for sample code. * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http') loHttp = CreateObject('Chilkat.Http') * Implements the following CURL command: * curl "https://api.harvestapp.com/v2/contacts" \ * -H "Authorization: Bearer ACCESS_TOKEN" \ * -H "Harvest-Account-Id: ACCOUNT_ID" \ * -H "User-Agent: MyApp (yourname@example.com)" loHttp.SetRequestHeader("User-Agent","MyApp (yourname@example.com)") loHttp.SetRequestHeader("Authorization","Bearer ACCESS_TOKEN") loHttp.SetRequestHeader("Harvest-Account-Id","ACCOUNT_ID") * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbResponseBody = CreateObject('Chilkat.StringBuilder') lnSuccess = loHttp.QuickGetSb("https://api.harvestapp.com/v2/contacts",loSbResponseBody) IF (lnSuccess = 0) THEN ? loHttp.LastErrorText RELEASE loHttp RELEASE loSbResponseBody CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJResp = CreateObject('Chilkat.JsonObject') loJResp.LoadSb(loSbResponseBody) loJResp.EmitCompact = 0 ? "Response Body:" ? loJResp.Emit() lnRespStatusCode = loHttp.LastStatus ? "Response Status Code = " + STR(lnRespStatusCode) IF (lnRespStatusCode >= 400) THEN ? "Response Header:" ? loHttp.LastHeader ? "Failed." RELEASE loHttp RELEASE loSbResponseBody RELEASE loJResp CANCEL ENDIF * Sample JSON response: * { * "contacts": [ * { * "id": 4706479, * "title": "Owner", * "first_name": "Jane", * "last_name": "Doe", * "email": "janedoe@example.com", * "phone_office": "(203) 697-8885", * "phone_mobile": "(203) 697-8886", * "fax": "(203) 697-8887", * "created_at": "2017-06-26T21:20:07Z", * "updated_at": "2017-06-26T21:27:07Z", * "client": { * "id": 5735774, * "name": "ABC Corp" * } * }, * { * "id": 4706453, * "title": "Manager", * "first_name": "Richard", * "last_name": "Roe", * "email": "richardroe@example.com", * "phone_office": "(318) 515-5905", * "phone_mobile": "(318) 515-5906", * "fax": "(318) 515-5907", * "created_at": "2017-06-26T21:06:55Z", * "updated_at": "2017-06-26T21:27:20Z", * "client": { * "id": 5735776, * "name": "123 Industries" * } * } * ], * "per_page": 100, * "total_pages": 1, * "total_entries": 2, * "next_page": null, * "previous_page": null, * "page": 1, * "links": { * "first": "https://api.harvestapp.com/v2/contacts?page=1&per_page=100", * "next": null, * "previous": null, * "last": "https://api.harvestapp.com/v2/contacts?page=1&per_page=100" * } * } * Sample code for parsing the JSON response... * Use the following online tool to generate parsing code from sample JSON: * Generate Parsing Code from JSON lnPer_page = loJResp.IntOf("per_page") lnTotal_pages = loJResp.IntOf("total_pages") lnTotal_entries = loJResp.IntOf("total_entries") lcNext_page = loJResp.StringOf("next_page") lcPrevious_page = loJResp.StringOf("previous_page") lnPage = loJResp.IntOf("page") lcLinksFirst = loJResp.StringOf("links.first") lcLinksNext = loJResp.StringOf("links.next") lcLinksPrevious = loJResp.StringOf("links.previous") lcLinksLast = loJResp.StringOf("links.last") i = 0 lnCount_i = loJResp.SizeOfArray("contacts") DO WHILE i < lnCount_i loJResp.I = i lnId = loJResp.IntOf("contacts[i].id") lcTitle = loJResp.StringOf("contacts[i].title") lcFirst_name = loJResp.StringOf("contacts[i].first_name") lcLast_name = loJResp.StringOf("contacts[i].last_name") lcEmail = loJResp.StringOf("contacts[i].email") lcPhone_office = loJResp.StringOf("contacts[i].phone_office") lcPhone_mobile = loJResp.StringOf("contacts[i].phone_mobile") lcFax = loJResp.StringOf("contacts[i].fax") lcCreated_at = loJResp.StringOf("contacts[i].created_at") lcUpdated_at = loJResp.StringOf("contacts[i].updated_at") lnClientId = loJResp.IntOf("contacts[i].client.id") lcClientName = loJResp.StringOf("contacts[i].client.name") i = i + 1 ENDDO RELEASE loHttp RELEASE loSbResponseBody RELEASE loJResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.