Bug in PHP wrapper 1.4.7

There is a bug in the PHP wrapper 1.4.7 which prevents to create campaigns with subscriber list segments. The lines 1269 to 1278 should read as follows:

        $_seg = '';
        if ($listSegments != "")
        {
            $_seg = array(  );
            if ( is_array( $listSegments ) )
            {
                for($i=0;$i<count($listSegments);$i++){
                    foreach ( $listSegments[$i] as $k => $v ) {
                        $_seg['List'][$i][$k] = $v;
                    }
                }
            }
        }

This allows you to pass in an array formatted like this:
$listSegments[] = array( 'ListID' => $listId, 'Name' => $segment_1 );
$listSegments[] = array( 'ListID' => $listId, 'Name' => $segment_2 );

Kind regards,
Pete

jamesd jamesd, 6 years ago

Hey Joomailer,

The code on GitHub for the current version (1.4.7) represents exactly what you have written above:

http://github.com/campaignmonitor/campaignmonitor-php/blob/master/CMBase.php#L1269

Could you please explain what you mean when you say there is a bug in the wrapper?

Joomailer Joomailer, 6 years ago

Ouch. Looks like I copied from the wrong file when editing the above post. Sorry for the confusion. However, I now put the correct code into the first post.

What I mean with bug is that the current code of version 1.4.7 does not allow you to use segments because it doesn't create associative arrays which you need to pass segments. For example the array these lines of code create need to have a structure like: array( 'ListID' => $listId, 'Name' => $segment_1 ); and in the current version it would result in: array( 0 => $listID, 1 => $segment_1); That returns the error message (which i've read a zillion times when trying to use segments before I figured out why it can't work): "The Segments you supplied are invalid.".

Kind regards,
Pete


-----------------------------------------------------------------------------------
Joomailer.com - Campaign Monitor Integration for Joomla!
-----------------------------------------------------------------------------------
jamesd jamesd, 6 years ago

That makes more sense. Thanks for spotting that.

I've just tested your proposed change and committed the fix: http://github.com/campaignmonitor/campaignmonitor-php/commit/b28b08fd08e3eaefc7362f5a6421cbbc321cc84c

Download 1.4.8 here: http://github.com/downloads/campaignmonitor/campaignmonitor-php/campaignmonitor-php-1.4.8.zip

Thanks again,
James

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