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 - Restore a Deleted ContactRestores a previously deleted contact with a given id. For more information, see https://v3.developer.constantcontact.com/api_guide/contacts_delete.html#cURL
Use ChilkatAx-win32.pkg Procedure Test Handle hoHttp Boolean iSuccess Handle hoJson Variant vSbRequestBody Handle hoSbRequestBody Variant vResp Handle hoResp Variant vSbResponseBody Handle hoSbResponseBody Handle hoJResp Integer iRespStatusCode String sContact_id String sFirst_name String sLast_name String sUpdate_source String sCreate_source String sCreated_at String sUpdated_at 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 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 PUT \ // https://api.cc.email/v3/contacts/{contact_id} \ // -H 'Accept: application/json' \ // -H 'Authorization: Bearer {access_token}' \ // -H 'Cache-Control: no-cache' \ // -H 'Content-Type: application/json' \ // -d '{ // // "first_name": "John", // "last_name": "Byrd", // "email_address": { // "address": "example@example.com", // "permission_to_send": "explicit" // }, // "update_source": "Contact", // "list_memberships":["{list_id1}","{list_id2}"] // }' // 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. // { // "first_name": "John", // "last_name": "Byrd", // "email_address": { // "address": "example@example.com", // "permission_to_send": "explicit" // }, // "update_source": "Contact", // "list_memberships": [ // "{list_id1}", // "{list_id2}" // ] // } Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get ComUpdateString Of hoJson "first_name" "John" To iSuccess Get ComUpdateString Of hoJson "last_name" "Byrd" To iSuccess Get ComUpdateString Of hoJson "email_address.address" "example@example.com" To iSuccess Get ComUpdateString Of hoJson "email_address.permission_to_send" "explicit" To iSuccess Get ComUpdateString Of hoJson "update_source" "Contact" To iSuccess Get ComUpdateString Of hoJson "list_memberships[0]" "{list_id1}" To iSuccess Get ComUpdateString Of hoJson "list_memberships[1]" "{list_id2}" To iSuccess // Adds the "Authorization: Bearer ACCESS_TOKEN" header. Set ComAuthToken Of hoHttp To "ACCESS_TOKEN" Send ComSetRequestHeader To hoHttp "Accept" "application/json" Send ComSetRequestHeader To hoHttp "Content-Type" "application/json" Send ComSetRequestHeader To hoHttp "Cache-Control" "no-cache" Get Create (RefClass(cComChilkatStringBuilder)) To hoSbRequestBody If (Not(IsComObjectCreated(hoSbRequestBody))) Begin Send CreateComObject of hoSbRequestBody End Get pvComObject of hoSbRequestBody to vSbRequestBody Get ComEmitSb Of hoJson vSbRequestBody To iSuccess Get pvComObject of hoSbRequestBody to vSbRequestBody Get ComPTextSb Of hoHttp "PUT" "https://api.cc.email/v3/contacts/{contact_id}" vSbRequestBody "utf-8" "application/json" False False 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}", // "first_name": "John", // "last_name": "Byrd", // "update_source": "Contact", // "create_source": "Account", // "created_at": "2013-04-01T15:07:07-04:00", // "updated_at": "2018-02-20T16:47:40-05:00", // "email_address": { // "address": "example@example.com", // "permission_to_send": "implicit", // "created_at": "2013-04-01T15:07:07-04:00", // "updated_at": "2018-02-20T16:47:40-05:00", // "opt_in_source": "Account", // "opt_in_date": "2015-03-17T11:13:28-04:00", // "confirm_status": "off" // } // } // 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 "first_name" To sFirst_name Get ComStringOf Of hoJResp "last_name" To sLast_name Get ComStringOf Of hoJResp "update_source" To sUpdate_source 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 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 End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.