Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 268
Darkisa Avatar asked Jan 28 '23 18:01

Darkisa


1 Answers

please try following code to generate lower_case_md5_hashed_email_address

require 'digest'
lower_case_md5_hashed_email_address = Digest::MD5.hexdigest('[email protected]'.downcase)

for more detail please check reference link

like image 55
Ganesh Avatar answered Jan 31 '23 23:01

Ganesh