Inconsistent data formatting on the API?

Strange one this.  We're looking at using the API to develop a birthday system.

Basically the script uses GetActive to retrieve the subscribers, then iterates through the birthday custom field and sends an email out to those that match today.

Everything seemed to be going fine, then I added my name name to the database manually through campaign monitor, and the data for that record comes out completely differently to the ones added via csv.

heres a snapshot:

Array
(
    [Subscriber] => Array
        (
           
            [6] => Array
                (
                    [EmailAddress] => xxx@xxx.com
                    [Name] => xxxxx
                    [Date] => 2009-02-02 12:52:00
                    [State] => Active
                    [CustomFields] => Array
                        (
                            [0] => Array
                                (
                                    [SubscriberCustomField] => Array
                                        (
                                            [Key] => Birthday
                                        )

                                )

                            [6] => Array
                                (
                                    [SubscriberCustomField] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [Value] => 23/10/1986
                                                )

                                            [1] => Array
                                                (
                                                    [Key] => Local Bar
                                                    [Value] => Leeds
                                                )

                                            [2] => Array
                                                (
                                                    [Key] => Gender
                                                    [Value] => Female
                                                )

                                            [3] => Array
                                                (
                                                    [Key] => Location
                                                    [Value] => leeds
                                                )

                                            [4] => Array
                                                (
                                                    [Key] => Country
                                                    [Value] => United Kingdom
                                                )

                                        )

                                )

                        )

                )

           

            [90] => Array
                (
                    [EmailAddress] => xxxx@gmail.com
                    [Name] => xxxxxx
                    [Date] => 2009-02-25 14:36:00
                    [State] => Active
                    [CustomFields] => Array
                        (
                            [0] => Array
                                (
                                    [SubscriberCustomField] => Array
                                        (
                                            [Key] => Mobile Phone
                                        )

                                )

                            [90] => Array
                                (
                                    [SubscriberCustomField] => Array
                                        (
                                            [0] => Array
                                                (
                                                    [Key] => Birthday
                                                )

                                            [73] => Array
                                                (
                                                    [Value] => 25/02/1973
                                                )

                                            [74] => Array
                                                (
                                                    [Key] => Local Bar
                                                    [Value] => Leeds
                                                )

                                            [75] => Array
                                                (
                                                    [Key] => Home Address
                                                )

                                            [76] => Array
                                                (
                                                    [Key] => Source
                                                )

                                            [77] => Array
                                                (
                                                    [Key] => Mobile number (Private field)
                                                )

                                            [78] => Array
                                                (
                                                    [Key] => Mobile number
                                                )

                                            [79] => Array
                                                (
                                                    [Key] => Gender
                                                )

                                            [80] => Array
                                                (
                                                    [Key] => Location
                                                )

                                            [81] => Array
                                                (
                                                    [Key] => Country
                                                )

                                        )

                                )

                        )

                )

        )

)

Basically, any records added by importing via CSV have the structure as per record 6, and any that are manually added have the structure as per record 9.

This makes it impossible for me to walk through the array and get the correct information consistently.

Any ideas as to why this is happenning?

Ken Ken, 7 years ago

Hi,

This is interesting. I need a bit more info, and then I can dig around. Could you email support@campaignmonitor.com with the names of the Client and List your working with and your APIKey? Also refer to this forum post so we know it's you.

Thanks!


http://www.campaignmonitor.com
sagalout, 7 years ago

Hi Ken,

Unfortunately I exported then re-imported the database, and everything is now in the same order (as per record 90).

I know the client has recently added and amended their custom fields - could that be the reason?

Cheers

Dave

shane, 7 years ago

I'm getting this problem too. It seems like it happens if I have more than five custom fields, the first one's key/value pair gets split just like above. I tried deleting the field that got split and re-adding it, but that just put it at the bottom of the list and then the next field (the one now at the top) got split instead.

I noticed that a subscription that was processed with five custom fields doesn't have this problem, but one with six custom fields does.

Any help would be very appreciated -- getting around this would be a giant hack on my end.

Thanks!

Shane

Ken Ken, 7 years ago

Hi Shane,

We'll need a bit more info to figure out what the problem might be. Could you email support@campaignmonitor.com with the names of the Client and List your working with and your APIKey? Also refer to this forum post so we know it's you.

Thanks!


http://www.campaignmonitor.com
blad, 7 years ago

I experienced the same problem on Friday and have been in touch with CM who are looking into it. Bascially, the xml2array function in PHP looks like it might be doing this to the XML data.

My solution was to rejig CMBase.php to return all data in xml format, then I use SimpleXMLElement to do all my processing. Much neater.

Cheers
Justin

jamesd jamesd, 7 years ago

Hi all,

I've recently updated the PHP wrapper, as there was a bug in the conversion from XML to a PHP array. I've committed the changes at http://code.google.com/p/campaignmonitor-php/

If you use the latest version (1.4.1) of the PHP wrapper and you should see that the resulting PHP array is formed correctly.

Hope this helps.

Join 200,000 companies around the world that use Campaign Monitor to run email marketing campaigns that deliver results for their business.

Get started for free
1-888-533-8098