Visual FoxPro Requires Chilkat v11.0.0+
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loVault
LOCAL loEntry
LOCAL loTokens
LOCAL lnLoaded
LOCAL loHttp
LOCAL loResp
lnSuccess = 0
* Assumes Chilkat is unlocked. See Global Unlock Sample.
loVault = CreateObject('Chilkat.Secrets')
loVault.Location = "local_manager"
loVault.AutoSplit = 1
loEntry = CreateObject('Chilkat.JsonObject')
loEntry.UpdateString("appName","ConstantContactV3")
loEntry.UpdateString("service","OAuth2")
loEntry.UpdateString("username","my-account")
loTokens = CreateObject('Chilkat.JsonObject')
lnLoaded = loVault.GetSecretJson(loEntry,loTokens)
IF (lnLoaded <> 1) THEN
? "Run the desktop authorization example using this account and store."
RELEASE loVault
RELEASE loEntry
RELEASE loTokens
CANCEL
ENDIF
IF (loTokens.JsonTypeOf("access_token") <> 1) THEN
? "The saved authorization has no access token."
RELEASE loVault
RELEASE loEntry
RELEASE loTokens
CANCEL
ENDIF
loHttp = CreateObject('Chilkat.Http')
loHttp.RequireSslCertVerify = 1
loHttp.AuthToken = loTokens.StringOf("access_token")
loResp = CreateObject('Chilkat.HttpResponse')
* Obtain the selected contact ID from the email lookup example.
loHttp.SetUrlVar("contactId","CONTACT_ID")
lnSuccess = loHttp.HttpNoBody("DELETE","https://api.cc.email/v3/contacts/{$contactId}",loResp)
IF (loResp.StatusCode = 404) THEN
? "Contact ID not found in this account."
RELEASE loVault
RELEASE loEntry
RELEASE loTokens
RELEASE loHttp
RELEASE loResp
CANCEL
ENDIF
IF ((lnSuccess <> 1) OR (loResp.StatusCode <> 204)) THEN
? "Expected HTTP 204. Received " + STR(loResp.StatusCode)
IF (loResp.StatusCode = 401) THEN
? "Refresh the saved access token or authorize again."
ENDIF
RELEASE loVault
RELEASE loEntry
RELEASE loTokens
RELEASE loHttp
RELEASE loResp
CANCEL
ENDIF
? "Contact deleted and list memberships removed."
RELEASE loVault
RELEASE loEntry
RELEASE loTokens
RELEASE loHttp
RELEASE loResp