Visual Basic 6.0 Requires Chilkat v11.0.0+
Visual Basic 6.0
Constant Contact V3: Create a contact list
See more Constant Contact Examples
Create a list with a unique name and a short description. Save the returned list_id with your application’s list record and use it in the membership examples. The new list starts empty. 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 body As New ChilkatJsonObject
success = body.UpdateString("name","Workshop announcements")
success = body.UpdateString("description","People who requested workshop updates")
success = http.HttpJson("POST","https://api.cc.email/v3/contact_lists",body,"application/json",resp)
If (resp.StatusCode = 409) Then
Debug.Print "A conflicting list already exists. Check the existing lists before retrying."
Exit Sub
End If
If ((success <> 1) Or (resp.StatusCode <> 201)) Then
Debug.Print "Expected HTTP 201. 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 created As New ChilkatJsonObject
success = created.Load(resp.BodyStr)
If (success <> 1) Then
Debug.Print "Expected a JSON response."
Exit Sub
End If
If ((created.JsonTypeOf("list_id") <> 1) Or (created.StringOfEquals("list_id","",1) = 1)) Then
Debug.Print "Missing list_id in the response."
Exit Sub
End If
Debug.Print "Created " & created.StringOf("name") & ". List ID: " & created.StringOf("list_id")