Classic ASP Requires Chilkat v11.0.0+
Classic ASP
Constant Contact V3: Read every page of list members
See more Constant Contact Examples
Filter the contacts collection with lists and a list ID. To query multiple lists together, supply their comma-separated IDs. Follow the returned cursor links and report the total after the last page. The default contacts query excludes deleted records. A list member can still have unsubscribed email permission. 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")
success = http.SetUrlVar("list","LIST_ID")
set url = Server.CreateObject("Chilkat.StringBuilder")
success = url.Append("https://api.cc.email/v3/contacts?lists={$list}&limit=50")
set page = Server.CreateObject("Chilkat.JsonObject")
total = 0
Do While (url.Length > 0)
success = http.HttpNoBody("GET",url.GetAsString(),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
success = page.Load(resp.BodyStr)
count = page.SizeOfArray("contacts")
If ((success <> 1) Or (count < 0)) Then
Response.Write "<pre>" & Server.HTMLEncode( "Expected a page of contacts.") & "</pre>"
Response.End
End If
i = 0
Do While (i < count)
page.I = i
Response.Write "<pre>" & Server.HTMLEncode( page.StringOf("contacts[i].contact_id") & " " & page.StringOf("contacts[i].email_address.address")) & "</pre>"
i = i + 1
Loop
total = total + count
url.Clear
If (page.JsonTypeOf("_links.next.href") = 1) Then
success = url.Append(page.StringOf("_links.next.href"))
' The documented cursor link is relative to api.cc.email.
If (url.StartsWith("/v3/contacts?",1) <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( "Unexpected pagination link. Stopped before following it.") & "</pre>"
Response.End
End If
success = url.Prepend("https://api.cc.email")
End If
Loop
Response.Write "<pre>" & Server.HTMLEncode( "List members read: " & total) & "</pre>"
%>
</body>
</html>