Bug in PHP API

function subscriberAddRedundant( $email, $name, $list_id = null )
{
    $added = $this->subscriberAdd( $email, $name, $list_id );
            
    if ( $added && $added['Code'] == '0' )
    {
        $subscribed = $this->subscribersGetIsSubscribed( $email, $list_id );
        // Must have unsubscribed, so resubscribe
        if ( $subscribed == 'False' )
        {
            // since we're internal, we'll just call the method with full parameters rather
            // than go through a secondary wrapper function.
            $added = $this->subscriberAdd( $email, $name, $list_id, true );
            return $added;
        }
    }
    
    return $added;
}

should be:

function subscriberAddRedundant( $email, $name, $list_id = null )
{
    $added = $this->subscriberAdd( $email, $name, $list_id );        
        
    if ( $added && $added['Result']['Code'] == '204' )
    {
        $subscribed = $this->subscribersGetIsSubscribed( $email, $list_id );    
    
        // Must have unsubscribed, so resubscribe
        if ( $subscribed['anyType'] == 'False' )
        {
            // since we're internal, we'll just call the method with full parameters rather
            // than go through a secondary wrapper function.
            $added = $this->subscriberAdd( $email, $name, $list_id, true );
            return $added;
        }
    }
        
    return $added;
}
Ben Ben, 8 years ago

Thank you very much for posting this bug, we've updated the sample with your fix.

See why 200,000 companies worldwide love Campaign Monitor.

From Australia to Zimbabwe, and everywhere in between, companies count on Campaign Monitor for email campaigns that boost the bottom line.

Get started for free