Adding address to mailchimp using Gibbon gem

457 views Asked by At

Im using the gibbon 0.4.6 with ruby 1.9.3p392, and I tried to add the address of my contacts but I couldn't find the correct format of the parameters.

 respuesta = gb.listSubscribe({
    :id => lista_id, :email_address => email, 
    :merge_vars => {'FNAME' => nombre, 'LNAME' => apellido, 
      'MMERGE3' => ['addr1' => 'aqui', 'addr2' => 'Alla', 'city' => 'Mexico DF', 
                    'zip' => '06700', 'country' => 'MX']
    }
  })

Update

As Amro suggested, now Im using Gibbon 1.0, but I have the same problem:

I used this

respuesta = gb.lists.subscribe({
    :id => lista_id, :email => {:email => email}, 
    :merge_vars => {'FNAME' => nombre, 'LNAME' => apellido, 
      'MMERGE3' => {'addr1' => 'aqui', 'addr2' => 'Alla', 'city' => 'Mexico DF', 'zip'  => '06700', 'country' => 'MX'},
      'MMERGE4' => 'Mi nota '
      }
  })

But the address(MMERGE3) wasn't registered at MailChimp.

Any idea is welcome.

1

There are 1 answers

1
Amro On

Your current code looks reasonable to me. Have you tried also passing "update_existing" with a value of true? If that address is already subscribed then it won't work otherwise since "update_existing" defaults to false.

Old Answer for API 1.3

I'm Gibbon's maintainer. In this case, MailChimp's docs say the type is an "array," but they mean an associative array (i.e. a Ruby hash). So try something like this:

respuesta = gb.listSubscribe({
    :id => lista_id, :email_address => email, 
    :merge_vars => {'FNAME' => nombre, 'LNAME' => apellido, 
      'MMERGE3' => {'addr1' => 'aqui', 'addr2' => 'Alla', 'city' => 'Mexico DF', 
                    'zip' => '06700', 'country' => 'MX'}
    }
  })

Also, API 1.3 has been deprecated. I suggest upgrading to Gibbon 1.0, which hits MailChimp API 2.0. The syntax is a little different so be sure to check out the 2.0 docs and Gibbon's updated README here.