ruby-on-railsgibbon

Rails md5 hash, gibbon, and mailchimp


I am using the gibbon gem to connect to MailChimp. I am trying to retrieve a user from my list using their email address. According to: https://github.com/amro/gibbon the way to do this is the following:

gibbon.lists(list_id).members(lower_case_md5_hashed_email_address).retrieve

I can get everything to work e.g. adding a new user

   gibbon.lists(list_id).members
      .create(body: {email_address: "#{email}", status: 'subscribed'} )

This works fine, but if I try to retrieve one record I get an error: Gibbon::MailChimpError: bad URI

I am 95% sure it's because I am not submitting the email as a lower_case_md5_hashed_email_address

Right now I am submitting the request as follows:

gibbon.lists(list_id).members({email: email})
  .update(body: {status: 'unsubscribed'} )

What exactly is the lower_case_md5_hashed_email_address format?


Solution

  • please try following code to generate lower_case_md5_hashed_email_address

    require 'digest'
    lower_case_md5_hashed_email_address = Digest::MD5.hexdigest('YourMail@example.com'.downcase)
    

    for more detail please check reference link