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) Constant Contact - Get Contact by Email AddressGet the contact details for a given email address. For more information, see https://v3.developer.constantcontact.com/api_guide/contacts_create.html#cURL1
LOCAL loHttp LOCAL lnSuccess LOCAL loSbResponseBody LOCAL loJResp LOCAL lnRespStatusCode LOCAL lcContact_id LOCAL lcEmail_addressAddress LOCAL lcEmail_addressPermission_to_send LOCAL lcEmail_addressCreated_at LOCAL lcEmail_addressUpdated_at LOCAL lcEmail_addressOpt_in_source LOCAL lcEmail_addressOpt_in_date LOCAL lcEmail_addressConfirm_status LOCAL lcFirst_name LOCAL lcLast_name LOCAL lcJob_title LOCAL lcCompany_name LOCAL lnBirthday_month LOCAL lnBirthday_day LOCAL lcAnniversary LOCAL lcCreate_source LOCAL lcCreated_at LOCAL lcUpdated_at LOCAL i LOCAL lnCount_i * 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 -X GET \ * 'https://api.cc.email/v3/contacts?email=new_contact_email&status=all' \ * -H 'Accept: application/json' \ * -H 'Authorization: Bearer ACCESS_TOKEN' \ * -H 'Content-Type: application/json' \ * -H 'Postman-Token: 98980ee6-b99f-41a9-9a7a-3b5651d2ea7f' \ * -H 'cache-control: no-cache' * Use the following online tool to generate HTTP code from a CURL command * Convert a cURL Command to HTTP Source Code loHttp.SetRequestHeader("Accept","application/json") * Adds the "Authorization: Bearer ACCESS_TOKEN" header. loHttp.AuthToken = "ACCESS_TOKEN" loHttp.SetRequestHeader("Postman-Token","98980ee6-b99f-41a9-9a7a-3b5651d2ea7f") loHttp.SetRequestHeader("Content-Type","application/json") loHttp.SetRequestHeader("cache-control","no-cache") * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbResponseBody = CreateObject('Chilkat.StringBuilder') lnSuccess = loHttp.QuickGetSb("https://api.cc.email/v3/contacts?email=danipper@example.com&status=all",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: * (Sample code for parsing the JSON response is shown below) * { * "contacts": [ * { * "contact_id": "8207fa8e-13dd-11eb-8a66-fa163e37306a", * "email_address": { * "address": "danipper@example.com", * "permission_to_send": "implicit", * "created_at": "2020-10-21T20:39:25Z", * "updated_at": "2020-10-21T20:39:25Z", * "opt_in_source": "Account", * "opt_in_date": "2020-10-21T20:39:25Z", * "confirm_status": "off" * }, * "first_name": "David", * "last_name": "Nipper", * "job_title": "Musician", * "company_name": "Acme Corp.", * "birthday_month": 11, * "birthday_day": 24, * "anniversary": "2006-11-15", * "create_source": "Account", * "created_at": "2020-10-21T20:39:25Z", * "updated_at": "2020-10-21T20:39:25Z" * } * ] * } * Sample code for parsing the JSON response... * Use the following online tool to generate parsing code from sample JSON: * Generate Parsing Code from JSON i = 0 lnCount_i = loJResp.SizeOfArray("contacts") DO WHILE i < lnCount_i loJResp.I = i lcContact_id = loJResp.StringOf("contacts[i].contact_id") lcEmail_addressAddress = loJResp.StringOf("contacts[i].email_address.address") lcEmail_addressPermission_to_send = loJResp.StringOf("contacts[i].email_address.permission_to_send") lcEmail_addressCreated_at = loJResp.StringOf("contacts[i].email_address.created_at") lcEmail_addressUpdated_at = loJResp.StringOf("contacts[i].email_address.updated_at") lcEmail_addressOpt_in_source = loJResp.StringOf("contacts[i].email_address.opt_in_source") lcEmail_addressOpt_in_date = loJResp.StringOf("contacts[i].email_address.opt_in_date") lcEmail_addressConfirm_status = loJResp.StringOf("contacts[i].email_address.confirm_status") lcFirst_name = loJResp.StringOf("contacts[i].first_name") lcLast_name = loJResp.StringOf("contacts[i].last_name") lcJob_title = loJResp.StringOf("contacts[i].job_title") lcCompany_name = loJResp.StringOf("contacts[i].company_name") lnBirthday_month = loJResp.IntOf("contacts[i].birthday_month") lnBirthday_day = loJResp.IntOf("contacts[i].birthday_day") lcAnniversary = loJResp.StringOf("contacts[i].anniversary") lcCreate_source = loJResp.StringOf("contacts[i].create_source") lcCreated_at = loJResp.StringOf("contacts[i].created_at") lcUpdated_at = loJResp.StringOf("contacts[i].updated_at") i = i + 1 ENDDO RELEASE loHttp RELEASE loSbResponseBody RELEASE loJResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.