I have followed the WWWForm script reference to try to connect Unity with Mailchimp. According with the log, the form is sent without errors. Unfortunately Mailchimp did not stored any data.
This is my code:
public class EmailSendButton : MonoBehaviour {
public GameObject emailInputText;
private WWWForm form;
/// <summary>
/// In the Inspector we tell Unity to call this function when the button is clicked.
/// </summary>
public void onClick() {
StartCoroutine(SendToMailChimp());
}
// TODO It seems to be working but Mailchimp did not store anything
private IEnumerator SendToMailChimp() {
form = new WWWForm();
string email = emailInputText.GetComponent<UnityEngine.UI.Text>().text;
form.AddField("mce-EMAIL", email); // I have also tried with: form.AddField("email", email);
WWW w = new WWW("http://bustogames.us11.list-manage.com/subscribe/post?u=8855252b454d05c2f913c1d2b&id=2ac022b22a", form);
yield return w;
if (!string.IsNullOrEmpty(w.error)) { print("Error sending the form: " + w.error); }
else { print("Form sent without errors"); }
}
}
This is the cut and paste code provided by Mailchimp:
<!-- Begin MailChimp Signup Form -->
<link href="//cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">
<style type="text/css">
#mc_embed_signup{background:#fff; clear:left; font:14px Helvetica,Arial,sans-serif; }
/* Add your own MailChimp form style overrides in your site stylesheet or in this style block.
We recommend moving this block and the preceding CSS link to the HEAD of your HTML file. */
</style>
<div id="mc_embed_signup">
<form action="//bustogames.us11.list-manage.com/subscribe/post?u=8855252b454d05c2f913c1d2b&id=2ac022b22a" method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
<div id="mc_embed_signup_scroll">
<label for="mce-EMAIL">Subscribe to our mailing list</label>
<input type="email" value="" name="EMAIL" class="email" id="mce-EMAIL" placeholder="email address" required>
<!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
<div style="position: absolute; left: -5000px;"><input type="text" name="b_8855252b454d05c2f913c1d2b_2ac022b22a" tabindex="-1" value=""></div>
<div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
</div>
</form>
</div>
<!--End mc_embed_signup-->