Classic ASP Requires Chilkat v11.0.0+
Classic ASP
Constant Contact V3: Find a contact by email address
See more Constant Contact Examples
Look up an exact email address across contact states, including deleted contacts. Pass the address as a query parameter so a literal plus sign survives URL encoding. Read the stored contact ID, email permission, and deletion marker. An empty contacts array means no match. Authorize the app first and use the same credential store.
Constant Contact developer guide
Chilkat Classic ASP Downloads
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0
' Assumes Chilkat is unlocked. See Global Unlock Sample.
set vault = Server.CreateObject("Chilkat.Secrets")
vault.Location = "local_manager"
vault.AutoSplit = 1
set entry = Server.CreateObject("Chilkat.JsonObject")
success = entry.UpdateString("appName","ConstantContactV3")
success = entry.UpdateString("service","OAuth2")
success = entry.UpdateString("username","my-account")
set tokens = Server.CreateObject("Chilkat.JsonObject")
loaded = vault.GetSecretJson(entry,tokens)
If (loaded <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Run the desktop authorization example using this account and store.") & "</pre>"
Response.End
End If
If (tokens.JsonTypeOf("access_token") <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "The saved authorization has no access token.") & "</pre>"
Response.End
End If
set http = Server.CreateObject("Chilkat.Http")
http.RequireSslCertVerify = 1
http.AuthToken = tokens.StringOf("access_token")
set resp = Server.CreateObject("Chilkat.HttpResponse")
set query = Server.CreateObject("Chilkat.HttpRequest")
query.HttpVerb = "GET"
query.AddParam "email","reader+newsletter@example.com"
query.AddParam "status","all"
success = http.HttpReq("https://api.cc.email/v3/contacts",query,resp)
If ((success <> 1) Or (resp.StatusCode <> 200)) Then
Response.Write "<pre>" & Server.HTMLEncode( "Expected HTTP 200. Received " & resp.StatusCode) & "</pre>"
If (resp.StatusCode = 401) Then
Response.Write "<pre>" & Server.HTMLEncode( "Refresh the saved access token or authorize again.") & "</pre>"
End If
Response.End
End If
set reply = Server.CreateObject("Chilkat.JsonObject")
success = reply.Load(resp.BodyStr)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Expected a JSON response.") & "</pre>"
Response.End
End If
count = reply.SizeOfArray("contacts")
If (count < 0) Then
Response.Write "<pre>" & Server.HTMLEncode( "The reply contained no contacts array.") & "</pre>"
Response.End
End If
If (count = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( "No contact has that email address.") & "</pre>"
Response.End
End If
i = 0
Do While (i < count)
reply.I = i
Response.Write "<pre>" & Server.HTMLEncode( "Contact ID: " & reply.StringOf("contacts[i].contact_id")) & "</pre>"
Response.Write "<pre>" & Server.HTMLEncode( "Email permission: " & reply.StringOf("contacts[i].email_address.permission_to_send")) & "</pre>"
If (reply.JsonTypeOf("contacts[i].deleted_at") = 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Deleted at: " & reply.StringOf("contacts[i].deleted_at")) & "</pre>"
End If
i = i + 1
Loop
%>
</body>
</html>