API v2 Syntax for Groups using lists/subscribe in FileMaker

196 views
Skip to first unread message

distillvide...@gmail.com

unread,
Sep 30, 2013, 11:10:26 PM9/30/13
to mailchimp-...@googlegroups.com
I am working on integrating a FileMaker Pro 12 database with MailChimp and need advice on syntax. Following the method of Douglas Alder (hbase.net) I am reworking and updating the scripts to the v2 API. For the most part it is going smoothly but I hit a snag on the syntax required to encode groups for a subscriber being added via lists/subscribe.format. 

FileMaker requires the construction of a URL very similar to that shown in Example 3 of the Serializing Data notes at MailChimp. Example 3, which refers to API 1.3, is:

    &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

If I read the API v2 notes correctly [groups] is an array in API v2. The question is how to assign an array to second element of Groupings (also an array). Using the format of the example rather than the actual string in FileMaker the URL I tried an expression like so:

apikey=<apikey - captured from your API dashboard>
&id=<list id - captured from lists/list>
&email[email]=<email_address>
&merge_vars[FNAME]=Firstname
&merge_vars[LNAME]=Lastname
&merge_vars[GROUPINGS][0][name]=Pets&
&merge_vars[GROUPINGS][0][groups]=groups[0][groups]=Cat&groups[1][groups]=Dog
&merge_vars[GROUPINGS][1][name]=Food
&merge_vars[GROUPINGS][1][groups]=groups[0][groups]=Meat&groups[1][groups]=Kibble
&double_optin=false&send_welcome=false

The comparable URL in FMP does add the subscriber but does not add the groups to which the subscriber is a member. Can anyone assist in helping with the required syntax for the arrays in Groupings and Groups? I tried several variations but so far nothing records the group data in MailChimp.

Many thanks. 

Background.

jesse

unread,
Oct 1, 2013, 6:14:51 AM10/1/13
to mailchimp-...@googlegroups.com
"groups" is an array (just like GROUPINGS is), so each group needs their own key=>value. Here's a general discussion on serializing arrays:
http://apidocs.mailchimp.com/gettingstarted/serialized_http_arrays.php

Really what you should do, though, is POST JSON instead of bothering with serializing data - a quick search shows there is support for that.


jesse
Reply all
Reply to author
Forward
0 new messages