AutoIt Requires Chilkat v11.0.0+
AutoIt
Constant Contact V3: Delete a contact by ID
See more Constant Contact Examples
Use the ID of the contact selected for deletion. Deletion removes all list memberships and sets the deletion timestamp. Unsubscribing is a separate operation that changes permission to send. A successful delete returns HTTP 204 with an empty body. To bring the record back, see Restore a deleted contact. Authorize the app first and use the same credential store.
Constant Contact developer guide
Chilkat AutoIt Downloads
Local $bSuccess = False
; Assumes Chilkat is unlocked. See Global Unlock Sample.
$oVault = ObjCreate("Chilkat.Secrets")
$oVault.Location = "local_manager"
$oVault.AutoSplit = True
$oEntry = ObjCreate("Chilkat.JsonObject")
$oEntry.UpdateString("appName","ConstantContactV3")
$oEntry.UpdateString("service","OAuth2")
$oEntry.UpdateString("username","my-account")
$oTokens = ObjCreate("Chilkat.JsonObject")
Local $bLoaded = $oVault.GetSecretJson($oEntry,$oTokens)
If ($bLoaded <> True) Then
ConsoleWrite("Run the desktop authorization example using this account and store." & @CRLF)
Exit
EndIf
If ($oTokens.JsonTypeOf("access_token") <> 1) Then
ConsoleWrite("The saved authorization has no access token." & @CRLF)
Exit
EndIf
$oHttp = ObjCreate("Chilkat.Http")
$oHttp.RequireSslCertVerify = True
$oHttp.AuthToken = $oTokens.StringOf("access_token")
$oResp = ObjCreate("Chilkat.HttpResponse")
; Obtain the selected contact ID from the email lookup example.
$oHttp.SetUrlVar("contactId","CONTACT_ID")
$bSuccess = $oHttp.HttpNoBody("DELETE","https://api.cc.email/v3/contacts/{$contactId}",$oResp)
If ($oResp.StatusCode = 404) Then
ConsoleWrite("Contact ID not found in this account." & @CRLF)
Exit
EndIf
If (($bSuccess <> True) Or ($oResp.StatusCode <> 204)) Then
ConsoleWrite("Expected HTTP 204. Received " & $oResp.StatusCode & @CRLF)
If ($oResp.StatusCode = 401) Then
ConsoleWrite("Refresh the saved access token or authorize again." & @CRLF)
EndIf
Exit
EndIf
ConsoleWrite("Contact deleted and list memberships removed." & @CRLF)