0

I have a web app and I will like to integrate mailchimp such that when a user clicks the signup button on the page, the user's email is added to a mailchimp subscription list but I'm having difficulty in doing so. The problem is, the button on the page is created in a javascript file using extjs. I do not have that much experience in developing web applications . I already downloaded the api for integrating with php. I saw this: " AJAX Mailchimp signup form integration " but it seems to have security issues. Can anyone help explain how to go about this?

Community
  • 1
  • 1
euniceadu
  • 868
  • 16
  • 34

1 Answers1

0

Have the ajax call directed to your server, with the user's email.
From there, use the API (you downloaded) to add the email, and return the outcome of their response to your client.

When you do it behind the scenes (your server to theirs), there is no security risk, as you are not exposing your API key.

Client side code:

Ext.Ajax.request({
    url: 'add_mail_to_chimp.php',
    params: {
        email: theUser_sEmail
    },
    success: function(response){
        var text = response.responseText;
        alert ('yay' + text);
    }
});
bldoron
  • 1,050
  • 4
  • 20
  • 37
  • bldoron, I tried your suggestion but the alert is displaying the contents of the php file(add_mail_to_chimp.php) instead of the return value of the function in the php file – euniceadu Sep 27 '12 at 12:37
  • I need more info, can you debug using firebug, or chrome tools? Tell me what you are sending/receiving. Are you sure that the php works? Have it do something small like `print('hello')`. – bldoron Sep 27 '12 at 15:19