Serialized How-tos

Folks using the serialized version of the API often have problems with building up the URLs. If you've never done this, there's a a more generalized version to get you up to speed. Then, these examples attempt to clarify the process.

  1. Using HTTP GET/POST
  2. Merge Var Arrays via HTTP GET/POST
  3. Merge Var Arrays with Groupings via HTTP GET/POST

Example 1: Using HTTP GET/POST. Here, we create a URL you can use to grab the data (curl, wget, raw sockets, etc).

#Return format is a php serialized array
    http://<dc>.api.mailchimp.com/1.3/?method=listMemberInfo
    &apikey=<apikey - captured from your API dashboard>
    &id=<list id - captured from lists()>
    &email_address=<email_address>
    &merge_vars=
    &output=php

#Return format is a JSON objects
    http://<dc>.api.mailchimp.com/1.3/?method=listMemberInfo
    &apikey=<apikey - captured from your API dashboard>
    &id=<list id - captured from lists()>
    &email_address=<email_address>
    &merge_vars=
    &output=json

Example 2: Setting Merge Var arrays when using HTTP GET/POST URL strings. This is just a sample of what your URL string should look like if you wish to pass Merge Vars and/or Interest Groups into the listSubscribe() function. Other functions that accept arrays of parameters should look similar.

#Return format is a JSON object
    http://<dc>.api.mailchimp.com/1.3/?method=listSubscribe
    &apikey=<apikey - captured from your API dashboard>
    &id=<list id - captured from lists()>
    &email_address=<email_address>   
    &merge_vars[FNAME]=Firstname
    &merge_vars[LNAME]=Lastname
    &merge_vars[INTERESTS]=Dogs,Cats,Shoes
    &output=json

Example 3: Setting Merge Var arrays that include the GROUPINGS array when using HTTP GET/POST URL strings. This example shows you how nested/multi-dimensional arrays should be passed in. This example's list has two Groupings, Pets and Food, and we have selected the Cat and Dog options for the Pets group, and the Meat and Kibble options for the Food group. Note that the 0 and 1 keys are not actually used for anything, but they need to be included to identify which data belongs in the arrays which are being passed.

#Return format is a JSON object
    http://<dc>.api.mailchimp.com/1.3/?method=listSubscribe
    &apikey=<apikey - captured from your API dashboard>
    &id=<list id - captured from lists()>
    &email_address=<email_address>   
    &merge_vars[FNAME]=Firstname
    &merge_vars[LNAME]=Lastname
    &merge_vars[GROUPINGS][0][name]=Pets
    &merge_vars[GROUPINGS][0][groups]=Cat,Dog
    &merge_vars[GROUPINGS][1][name]=Food
    &merge_vars[GROUPINGS][1][groups]=Meat,Kibble
    &output=json

No idea what the <dc> is? Read about "Submit URLs" in the documentation

Still not clear? Get in touch with us!