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
(DataFlex) Constant Contact: Create a ContactCreates a single contact. For more information, see https://v3.developer.constantcontact.com/api_guide/contacts_create.html#cURL2
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Boolean iSuccess Variant vJson Handle hoJson Variant vResp Handle hoResp Variant vSbResponseBody Handle hoSbResponseBody Handle hoJResp Integer iRespStatusCode String sContact_id String sEmail_addressAddress String sEmail_addressPermission_to_send String sEmail_addressCreated_at String sEmail_addressUpdated_at String sEmail_addressOpt_in_source String sEmail_addressOpt_in_date String sEmail_addressConfirm_status String sFirst_name String sLast_name String sJob_title String sCompany_name Integer iBirthday_month Integer iBirthday_day String sAnniversary String sCreate_source String sCreated_at String sUpdated_at String sTemp1 Boolean bTemp1 // This example assumes the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. Get Create (RefClass(cComChilkatHttp)) To hoHttp If (Not(IsComObjectCreated(hoHttp))) Begin Send CreateComObject of hoHttp End // 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" // } // } Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComUpdateString Of hoJson "email_address.address" "danipper@example.com" To iSuccess Get ComUpdateString Of hoJson "email_address.permission_to_send" "implicit" To iSuccess Get ComUpdateString Of hoJson "first_name" "David" To iSuccess Get ComUpdateString Of hoJson "last_name" "Nipper" To iSuccess Get ComUpdateString Of hoJson "job_title" "Musician" To iSuccess Get ComUpdateString Of hoJson "company_name" "Acme Corp." To iSuccess Get ComUpdateString Of hoJson "create_source" "Account" To iSuccess Get ComUpdateInt Of hoJson "birthday_month" 11 To iSuccess Get ComUpdateInt Of hoJson "birthday_day" 24 To iSuccess Get ComUpdateString Of hoJson "anniversary" "2006-11-15" To iSuccess Get ComUpdateString Of hoJson "steet_addresses.kind" "home" To iSuccess Get ComUpdateString Of hoJson "steet_addresses.street" "123 Kashmir Valley Road" To iSuccess Get ComUpdateString Of hoJson "steet_addresses.city" "Chicago" To iSuccess Get ComUpdateString Of hoJson "steet_addresses.state" "Illinois" To iSuccess Get ComUpdateString Of hoJson "steet_addresses.country" "United States" To iSuccess Send ComSetRequestHeader To hoHttp "content-type" "application/json" // Adds the "Authorization: Bearer ACCESS_TOKEN" header. Set ComAuthToken Of hoHttp To "ACCESS_TOKEN" Send ComSetRequestHeader To hoHttp "cache-control" "no-cache" Send ComSetRequestHeader To hoHttp "accept" "application/json" Get pvComObject of hoJson to vJson Get ComPostJson3 Of hoHttp "https://api.cc.email/v3/contacts" "application/json" vJson To vResp If (IsComObject(vResp)) Begin Get Create (RefClass(cComChilkatHttpResponse)) To hoResp Set pvComObject Of hoResp To vResp End Get ComLastMethodSuccess Of hoHttp To bTemp1 If (bTemp1 = False) Begin Get ComLastErrorText Of hoHttp To sTemp1 Showln sTemp1 Procedure_Return End Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody If (Not(IsComObjectCreated(hoSbResponseBody))) Begin Send CreateComObject of hoSbResponseBody End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComGetBodySb Of hoResp vSbResponseBody To iSuccess Get Create (RefClass(cComChilkatJsonObject)) To hoJResp If (Not(IsComObjectCreated(hoJResp))) Begin Send CreateComObject of hoJResp End Get pvComObject of hoSbResponseBody to vSbResponseBody Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess Set ComEmitCompact Of hoJResp To False Showln "Response Body:" Get ComEmit Of hoJResp To sTemp1 Showln sTemp1 Get ComStatusCode Of hoResp To iRespStatusCode Showln "Response Status Code = " iRespStatusCode If (iRespStatusCode >= 400) Begin Showln "Response Header:" Get ComHeader Of hoResp To sTemp1 Showln sTemp1 Showln "Failed." Send Destroy of hoResp Procedure_Return End Send Destroy of hoResp // 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 Get ComStringOf Of hoJResp "contact_id" To sContact_id Get ComStringOf Of hoJResp "email_address.address" To sEmail_addressAddress Get ComStringOf Of hoJResp "email_address.permission_to_send" To sEmail_addressPermission_to_send Get ComStringOf Of hoJResp "email_address.created_at" To sEmail_addressCreated_at Get ComStringOf Of hoJResp "email_address.updated_at" To sEmail_addressUpdated_at Get ComStringOf Of hoJResp "email_address.opt_in_source" To sEmail_addressOpt_in_source Get ComStringOf Of hoJResp "email_address.opt_in_date" To sEmail_addressOpt_in_date Get ComStringOf Of hoJResp "email_address.confirm_status" To sEmail_addressConfirm_status Get ComStringOf Of hoJResp "first_name" To sFirst_name Get ComStringOf Of hoJResp "last_name" To sLast_name Get ComStringOf Of hoJResp "job_title" To sJob_title Get ComStringOf Of hoJResp "company_name" To sCompany_name Get ComIntOf Of hoJResp "birthday_month" To iBirthday_month Get ComIntOf Of hoJResp "birthday_day" To iBirthday_day Get ComStringOf Of hoJResp "anniversary" To sAnniversary Get ComStringOf Of hoJResp "create_source" To sCreate_source Get ComStringOf Of hoJResp "created_at" To sCreated_at Get ComStringOf Of hoJResp "updated_at" To sUpdated_at End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.