Visual Basic 6.0 Requires Chilkat v11.0.0+
Visual Basic 6.0
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 Visual Basic 6.0 Downloads
Dim success As Long
success = 0
' Assumes Chilkat is unlocked. See Global Unlock Sample.
Dim vault As New ChilkatSecrets
vault.Location = "local_manager"
vault.AutoSplit = 1
Dim entry As New ChilkatJsonObject
success = entry.UpdateString("appName","ConstantContactV3")
success = entry.UpdateString("service","OAuth2")
success = entry.UpdateString("username","my-account")
Dim tokens As New ChilkatJsonObject
Dim loaded As Long
loaded = vault.GetSecretJson(entry,tokens)
If (loaded <> 1) Then
Debug.Print "Run the desktop authorization example using this account and store."
Exit Sub
End If
If (tokens.JsonTypeOf("access_token") <> 1) Then
Debug.Print "The saved authorization has no access token."
Exit Sub
End If
Dim http As New ChilkatHttp
http.RequireSslCertVerify = 1
http.AuthToken = tokens.StringOf("access_token")
Dim resp As New ChilkatHttpResponse
Dim query As New ChilkatHttpRequest
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
Debug.Print "Expected HTTP 200. Received " & resp.StatusCode
If (resp.StatusCode = 401) Then
Debug.Print "Refresh the saved access token or authorize again."
End If
Exit Sub
End If
Dim reply As New ChilkatJsonObject
success = reply.Load(resp.BodyStr)
If (success <> 1) Then
Debug.Print "Expected a JSON response."
Exit Sub
End If
Dim count As Long
count = reply.SizeOfArray("contacts")
If (count < 0) Then
Debug.Print "The reply contained no contacts array."
Exit Sub
End If
If (count = 0) Then
Debug.Print "No contact has that email address."
Exit Sub
End If
Dim i As Long
i = 0
Do While (i < count)
reply.I = i
Debug.Print "Contact ID: " & reply.StringOf("contacts[i].contact_id")
Debug.Print "Email permission: " & reply.StringOf("contacts[i].email_address.permission_to_send")
If (reply.JsonTypeOf("contacts[i].deleted_at") = 1) Then
Debug.Print "Deleted at: " & reply.StringOf("contacts[i].deleted_at")
End If
i = i + 1
Loop