Create custom signup block with mailchimp module? I'm looking for code examples for creating custom mailchimp signup forms that use the mailchimp api integration provided by the mailchimp module.

Context: I have a D7 site using a standard embedded sign-up form for mailchimp. I just recently switched the site to https, which unfortunately causes some browsers (e.g. firefox) to throw a scary message when a user clicks the submit button on the sign-up form, because standard mailchimp embedded forms can only use http.

The mailchimp module uses the mailchimp API, which allows secure connections, so that's the obvious solution. And the mailchimp module automatically provides a block for each list. But the module makes assumptions that I don't want. So, instead of the automatic block provided by the mailchimp module, I'd like to create my own block(s) with a sign-up form that uses the api, so that I have more control over the look and feel of the form. 

Also, I know the webform mailchimp module provides a mailchimp component for webform, (there's a good write up here) but I'd like to explore creating my own forms as a first step.
In the end, this is what I did:


Installed the mailchimp module and connected drupal to a list in mailchimp using normal instructions and an API key that mailchimp provides.
Created a new custom module that creates and displays blocks using standard hook_block_info and hook_block_view code.
Created a very simple form with hook_form, with a companion submit function, hook_form_submit, and add this form to the block(s) created above.
In hook_form_submit, I open a connection to the mailchimp api with:

$q = mailchimp_get_api_object();


Then subscribe the user with:

$success = $q-&gt;listSubscribe($list_id, $email, $merge_vars, 'html', TRUE, TRUE);


The above functions are documented in the mailchimp api.

So, in the end, I'm not really using the Drupal mailchimp module for anything other than providing access to mailchimp api over a secure connection (the drupal site is running https). The main advantage of this approach is complete control over the look and feel of the forms that appear in the blocks, and the actions taken when a user submits.

Another advantage: Because I'm using hook_form_submit to control processing once the form is submitted, I can add the form location (using request_path()) to the merge variables that are passed back to mailchimp. That way, the form is the same on every page that it appears, but the location is passed back to mailchimp as part of the sign-up process.