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.

200,000 companies around the world can't be wrong.

From Australia to Zimbabwe, and everywhere in between, companies count on 
Campaign Monitor for email campaigns that drive real business results.

Get started for free
1-888-533-8098