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: Create a ContactCreates a single contact. For more information, see https://v3.developer.constantcontact.com/api_guide/contacts_create.html#cURL2
LOCAL loHttp LOCAL lnSuccess LOCAL loJson LOCAL loResp 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 * 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 POST \ * https://api.cc.email/v3/contacts \ * -H 'accept: application/json' \ * -H 'authorization: Bearer {access_token}' \ * -H 'cache-control: no-cache' \ * -H 'content-type: application/json' \ * -d '{ * "email_address": { * "address": "danipper@example.com", * "permission_to_send": "implicit" * }, * "first_name": "David", * "last_name": "Nipper", * "job_title": "Musician", * "company_name": "Acme Corp.", * "create_source": "Account", * "birthday_month": 11, * "birthday_day": 24, * "anniversary": "2006-11-15", * "steet_addresses":{ * "kind":"home", * "street": "123 Kashmir Valley Road", * "city": "Chicago", * "state": "Illinois", * "country": "United States", * } * }' * Use the following online tool to generate HTTP code from a CURL command * Convert a cURL Command to HTTP Source Code * Use this online tool to generate code from sample JSON: * Generate Code to Create JSON * The following JSON is sent in the request body. * { * "email_address": { * "address": "danipper@example.com", * "permission_to_send": "implicit" * }, * "first_name": "David", * "last_name": "Nipper", * "job_title": "Musician", * "company_name": "Acme Corp.", * "create_source": "Account", * "birthday_month": 11, * "birthday_day": 24, * "anniversary": "2006-11-15", * "steet_addresses": { * "kind": "home", * "street": "123 Kashmir Valley Road", * "city": "Chicago", * "state": "Illinois", * "country": "United States" * } * } * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.JsonObject') loJson = CreateObject('Chilkat.JsonObject') loJson.UpdateString("email_address.address","danipper@example.com") loJson.UpdateString("email_address.permission_to_send","implicit") loJson.UpdateString("first_name","David") loJson.UpdateString("last_name","Nipper") loJson.UpdateString("job_title","Musician") loJson.UpdateString("company_name","Acme Corp.") loJson.UpdateString("create_source","Account") loJson.UpdateInt("birthday_month",11) loJson.UpdateInt("birthday_day",24) loJson.UpdateString("anniversary","2006-11-15") loJson.UpdateString("steet_addresses.kind","home") loJson.UpdateString("steet_addresses.street","123 Kashmir Valley Road") loJson.UpdateString("steet_addresses.city","Chicago") loJson.UpdateString("steet_addresses.state","Illinois") loJson.UpdateString("steet_addresses.country","United States") loHttp.SetRequestHeader("content-type","application/json") * Adds the "Authorization: Bearer ACCESS_TOKEN" header. loHttp.AuthToken = "ACCESS_TOKEN" loHttp.SetRequestHeader("cache-control","no-cache") loHttp.SetRequestHeader("accept","application/json") loResp = loHttp.PostJson3("https://api.cc.email/v3/contacts","application/json",loJson) IF (loHttp.LastMethodSuccess = 0) THEN ? loHttp.LastErrorText RELEASE loHttp RELEASE loJson CANCEL ENDIF * For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.StringBuilder') loSbResponseBody = CreateObject('Chilkat.StringBuilder') loResp.GetBodySb(loSbResponseBody) * 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 = loResp.StatusCode ? "Response Status Code = " + STR(lnRespStatusCode) IF (lnRespStatusCode >= 400) THEN ? "Response Header:" ? loResp.Header ? "Failed." RELEASE loResp RELEASE loHttp RELEASE loJson RELEASE loSbResponseBody RELEASE loJResp CANCEL ENDIF RELEASE loResp * Sample JSON response: * (Sample code for parsing the JSON response is shown below) * { * "contact_id": "{contact_id}", * "email_address": { * "address": "danipper@example.com", * "permission_to_send": "implicit", * "created_at": "2018-02-23T13:38:28-05:00", * "updated_at": "2018-02-23T13:38:28-05:00", * "opt_in_source": "Account", * "opt_in_date": "2018-02-23T13:38:28-05:00", * "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": "2018-02-23T13:38:28-05:00", * "updated_at": "2018-02-23T13:38:28-05:00" * } * Sample code for parsing the JSON response... * Use the following online tool to generate parsing code from sample JSON: * Generate Parsing Code from JSON lcContact_id = loJResp.StringOf("contact_id") lcEmail_addressAddress = loJResp.StringOf("email_address.address") lcEmail_addressPermission_to_send = loJResp.StringOf("email_address.permission_to_send") lcEmail_addressCreated_at = loJResp.StringOf("email_address.created_at") lcEmail_addressUpdated_at = loJResp.StringOf("email_address.updated_at") lcEmail_addressOpt_in_source = loJResp.StringOf("email_address.opt_in_source") lcEmail_addressOpt_in_date = loJResp.StringOf("email_address.opt_in_date") lcEmail_addressConfirm_status = loJResp.StringOf("email_address.confirm_status") lcFirst_name = loJResp.StringOf("first_name") lcLast_name = loJResp.StringOf("last_name") lcJob_title = loJResp.StringOf("job_title") lcCompany_name = loJResp.StringOf("company_name") lnBirthday_month = loJResp.IntOf("birthday_month") lnBirthday_day = loJResp.IntOf("birthday_day") lcAnniversary = loJResp.StringOf("anniversary") lcCreate_source = loJResp.StringOf("create_source") lcCreated_at = loJResp.StringOf("created_at") lcUpdated_at = loJResp.StringOf("updated_at") RELEASE loHttp RELEASE loJson RELEASE loSbResponseBody RELEASE loJResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.