Sample code for 30+ languages & platforms
DataFlex

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 DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoHttp
    Variant vSbResponseBody
    Handle hoSbResponseBody
    Handle hoJResp
    Integer iRespStatusCode
    String sContact_id
    String sEmail_addressAddress
    String sEmail_addressPermission_to_send
    String sEmail_addressCreated_at
    String sEmail_addressUpdated_at
    String sEmail_addressOpt_in_source
    String sEmail_addressOpt_in_date
    String sEmail_addressConfirm_status
    String sFirst_name
    String sLast_name
    String sUpdate_source
    String sCreate_source
    String sCreated_at
    String sUpdated_at
    String sJob_title
    String sCompany_name
    Integer iBirthday_month
    Integer iBirthday_day
    String sAnniversary
    Integer i
    Integer iCount_i
    String sTemp1

    Move False To iSuccess

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

    Get Create (RefClass(cComChilkatHttp)) To hoHttp
    If (Not(IsComObjectCreated(hoHttp))) Begin
        Send CreateComObject of hoHttp
    End

    // 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

    Send ComSetRequestHeader To hoHttp "content-type" "application/json"
    // Adds the "Authorization: Bearer ACCESS_TOKEN" header.
    Set ComAuthToken Of hoHttp To "ACCESS_TOKEN"
    Send ComSetRequestHeader To hoHttp "cache-control" "no-cache"
    Send ComSetRequestHeader To hoHttp "accept" "application/json"

    Get Create (RefClass(cComChilkatStringBuilder)) To hoSbResponseBody
    If (Not(IsComObjectCreated(hoSbResponseBody))) Begin
        Send CreateComObject of hoSbResponseBody
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComQuickGetSb Of hoHttp "https://api.cc.email/v3/contacts?lists={list_id},{list_id2}" vSbResponseBody To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoHttp To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatJsonObject)) To hoJResp
    If (Not(IsComObjectCreated(hoJResp))) Begin
        Send CreateComObject of hoJResp
    End
    Get pvComObject of hoSbResponseBody to vSbResponseBody
    Get ComLoadSb Of hoJResp vSbResponseBody To iSuccess
    Set ComEmitCompact Of hoJResp To False

    Showln "Response Body:"
    Get ComEmit Of hoJResp To sTemp1
    Showln sTemp1

    Get ComLastStatus Of hoHttp To iRespStatusCode
    Showln "Response Status Code = " iRespStatusCode
    If (iRespStatusCode >= 400) Begin
        Showln "Response Header:"
        Get ComLastHeader Of hoHttp To sTemp1
        Showln sTemp1
        Showln "Failed."
        Procedure_Return
    End

    // 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

    Move 0 To i
    Get ComSizeOfArray Of hoJResp "contacts" To iCount_i
    While (i < iCount_i)
        Set ComI Of hoJResp To i
        Get ComStringOf Of hoJResp "contacts[i].contact_id" To sContact_id
        Get ComStringOf Of hoJResp "contacts[i].email_address.address" To sEmail_addressAddress
        Get ComStringOf Of hoJResp "contacts[i].email_address.permission_to_send" To sEmail_addressPermission_to_send
        Get ComStringOf Of hoJResp "contacts[i].email_address.created_at" To sEmail_addressCreated_at
        Get ComStringOf Of hoJResp "contacts[i].email_address.updated_at" To sEmail_addressUpdated_at
        Get ComStringOf Of hoJResp "contacts[i].email_address.opt_in_source" To sEmail_addressOpt_in_source
        Get ComStringOf Of hoJResp "contacts[i].email_address.opt_in_date" To sEmail_addressOpt_in_date
        Get ComStringOf Of hoJResp "contacts[i].email_address.confirm_status" To sEmail_addressConfirm_status
        Get ComStringOf Of hoJResp "contacts[i].first_name" To sFirst_name
        Get ComStringOf Of hoJResp "contacts[i].last_name" To sLast_name
        Get ComStringOf Of hoJResp "contacts[i].update_source" To sUpdate_source
        Get ComStringOf Of hoJResp "contacts[i].create_source" To sCreate_source
        Get ComStringOf Of hoJResp "contacts[i].created_at" To sCreated_at
        Get ComStringOf Of hoJResp "contacts[i].updated_at" To sUpdated_at
        Get ComStringOf Of hoJResp "contacts[i].job_title" To sJob_title
        Get ComStringOf Of hoJResp "contacts[i].company_name" To sCompany_name
        Get ComIntOf Of hoJResp "contacts[i].birthday_month" To iBirthday_month
        Get ComIntOf Of hoJResp "contacts[i].birthday_day" To iBirthday_day
        Get ComStringOf Of hoJResp "contacts[i].anniversary" To sAnniversary
        Move (i + 1) To i
    Loop



End_Procedure