Sample code for 30+ languages & platforms
Visual FoxPro

Constant Contact - View List Members

See more Constant Contact Examples

View the list membership by making a GET call to the Contact Collection endpointl

Chilkat Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loHttp
LOCAL loSbResponseBody
LOCAL loJResp
LOCAL lnRespStatusCode
LOCAL lcContact_id
LOCAL lcEmail_addressAddress
LOCAL lcEmail_addressPermission_to_send
LOCAL lcEmail_addressCreated_at
LOCAL lcEmail_addressUpdated_at
LOCAL lcEmail_addressOpt_in_source
LOCAL lcEmail_addressOpt_in_date
LOCAL lcEmail_addressConfirm_status
LOCAL lcFirst_name
LOCAL lcLast_name
LOCAL lcUpdate_source
LOCAL lcCreate_source
LOCAL lcCreated_at
LOCAL lcUpdated_at
LOCAL lcJob_title
LOCAL lcCompany_name
LOCAL lnBirthday_month
LOCAL lnBirthday_day
LOCAL lcAnniversary
LOCAL i
LOCAL lnCount_i

lnSuccess = 0

* This example assumes the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.

loHttp = CreateObject('Chilkat.Http')

* Implements the following CURL command:

* curl -X GET \
*   'https://api.cc.email/v3/contacts?lists={list_id},{list_id2}' \
*   -H 'accept: application/json' \
*   -H 'authorization: Bearer {access_token}' \
*   -H 'cache-control: no-cache' \
*   -H 'content-type: application/json'

* Use the following online tool to generate HTTP code from a CURL command
* Convert a cURL Command to HTTP Source Code

loHttp.SetRequestHeader("content-type","application/json")
* Adds the "Authorization: Bearer ACCESS_TOKEN" header.
loHttp.AuthToken = "ACCESS_TOKEN"
loHttp.SetRequestHeader("cache-control","no-cache")
loHttp.SetRequestHeader("accept","application/json")

loSbResponseBody = CreateObject('Chilkat.StringBuilder')
lnSuccess = loHttp.QuickGetSb("https://api.cc.email/v3/contacts?lists={list_id},{list_id2}",loSbResponseBody)
IF (lnSuccess = 0) THEN
    ? loHttp.LastErrorText
    RELEASE loHttp
    RELEASE loSbResponseBody
    CANCEL
ENDIF

loJResp = CreateObject('Chilkat.JsonObject')
loJResp.LoadSb(loSbResponseBody)
loJResp.EmitCompact = 0

? "Response Body:"
? loJResp.Emit()

lnRespStatusCode = loHttp.LastStatus
? "Response Status Code = " + STR(lnRespStatusCode)
IF (lnRespStatusCode >= 400) THEN
    ? "Response Header:"
    ? loHttp.LastHeader
    ? "Failed."
    RELEASE loHttp
    RELEASE loSbResponseBody
    RELEASE loJResp
    CANCEL
ENDIF

* Sample JSON response:
* (Sample code for parsing the JSON response is shown below)

* {
*   "contacts": [
*     {
*       "contact_id": "{contact_id}",
*       "email_address": {
*         "address": "dprice@example.com",
*         "permission_to_send": "implicit",
*         "created_at": "2013-11-26T15:45:42-05:00",
*         "updated_at": "2013-11-26T15:45:42-05:00",
*         "opt_in_source": "Account",
*         "opt_in_date": "2013-11-26T15:45:42-05:00",
*         "confirm_status": "off"
*       },
*       "first_name": "David",
*       "last_name": "Price",
*       "update_source": "Account",
*       "create_source": "Account",
*       "created_at": "2013-11-26T15:45:42-05:00",
*       "updated_at": "2017-09-06T15:48:31-04:00"
*     },
*     {
*       "contact_id": "{contact_id}",
*       "email_address": {
*         "address": "jprice@example.com",
*         "permission_to_send": "implicit",
*         "created_at": "2013-11-26T15:45:50-05:00",
*         "updated_at": "2013-11-26T15:45:50-05:00",
*         "opt_in_source": "Account",
*         "opt_in_date": "2013-11-26T15:45:50-05:00",
*         "confirm_status": "off"
*       },
*       "first_name": "Jennifer",
*       "last_name": "Price",
*       "create_source": "Account",
*       "created_at": "2013-11-26T15:45:50-05:00",
*       "updated_at": "2013-11-26T15:45:50-05:00"
*     },
*     {
*       "contact_id": "{contact_id}",
*       "email_address": {
*         "address": "joe.jones@example.com",
*         "permission_to_send": "implicit",
*         "created_at": "2017-11-06T15:35:30-05:00",
*         "updated_at": "2017-11-06T15:35:30-05:00",
*         "opt_in_source": "Account",
*         "opt_in_date": "2017-11-06T15:35:30-05:00",
*         "confirm_status": "off"
*       },
*       "first_name": "Joe",
*       "last_name": "Jones",
*       "job_title": "Chief Innovation Officer",
*       "company_name": "RelativeGravity, Inc.",
*       "birthday_month": 11,
*       "birthday_day": 24,
*       "anniversary": "2006-11-15",
*       "create_source": "Account",
*       "created_at": "2017-11-06T15:35:30-05:00",
*       "updated_at": "2017-11-06T15:35:30-05:00"
*     },
*     {
*       "contact_id": "{contact_id}",
*       "email_address": {
*         "address": "mmiller@example.com",
*         "permission_to_send": "implicit",
*         "created_at": "2013-11-26T15:46:04-05:00",
*         "updated_at": "2013-11-26T15:46:04-05:00",
*         "opt_in_source": "Account",
*         "opt_in_date": "2013-11-26T15:46:04-05:00",
*         "confirm_status": "off"
*       },
*       "first_name": "Mike",
*       "last_name": "Miller.",
*       "create_source": "Account",
*       "created_at": "2013-11-26T15:46:04-05:00",
*       "updated_at": "2013-11-26T15:46:04-05:00"
*     },
*     {
*       "contact_id": "{contact_id}",
*       "email_address": {
*         "address": "sheryl.kavanaugh@example.com",
*         "permission_to_send": "implicit",
*         "created_at": "2013-11-26T15:46:10-05:00",
*         "updated_at": "2013-11-26T15:46:10-05:00",
*         "opt_in_source": "Account",
*         "opt_in_date": "2013-11-26T15:46:10-05:00",
*         "confirm_status": "off"
*       },
*       "first_name": "Sheryl",
*       "last_name": "Kavanaugh",
*       "create_source": "Account",
*       "created_at": "2013-11-26T15:46:10-05:00",
*       "updated_at": "2013-11-26T15:46:10-05:00"
*     }
*   ]
* }

* Sample code for parsing the JSON response...
* Use the following online tool to generate parsing code from sample JSON:
* Generate Parsing Code from JSON

i = 0
lnCount_i = loJResp.SizeOfArray("contacts")
DO WHILE i < lnCount_i
    loJResp.I = i
    lcContact_id = loJResp.StringOf("contacts[i].contact_id")
    lcEmail_addressAddress = loJResp.StringOf("contacts[i].email_address.address")
    lcEmail_addressPermission_to_send = loJResp.StringOf("contacts[i].email_address.permission_to_send")
    lcEmail_addressCreated_at = loJResp.StringOf("contacts[i].email_address.created_at")
    lcEmail_addressUpdated_at = loJResp.StringOf("contacts[i].email_address.updated_at")
    lcEmail_addressOpt_in_source = loJResp.StringOf("contacts[i].email_address.opt_in_source")
    lcEmail_addressOpt_in_date = loJResp.StringOf("contacts[i].email_address.opt_in_date")
    lcEmail_addressConfirm_status = loJResp.StringOf("contacts[i].email_address.confirm_status")
    lcFirst_name = loJResp.StringOf("contacts[i].first_name")
    lcLast_name = loJResp.StringOf("contacts[i].last_name")
    lcUpdate_source = loJResp.StringOf("contacts[i].update_source")
    lcCreate_source = loJResp.StringOf("contacts[i].create_source")
    lcCreated_at = loJResp.StringOf("contacts[i].created_at")
    lcUpdated_at = loJResp.StringOf("contacts[i].updated_at")
    lcJob_title = loJResp.StringOf("contacts[i].job_title")
    lcCompany_name = loJResp.StringOf("contacts[i].company_name")
    lnBirthday_month = loJResp.IntOf("contacts[i].birthday_month")
    lnBirthday_day = loJResp.IntOf("contacts[i].birthday_day")
    lcAnniversary = loJResp.StringOf("contacts[i].anniversary")
    i = i + 1
ENDDO

RELEASE loHttp
RELEASE loSbResponseBody
RELEASE loJResp