Mailchimp Java Example

Notice: A non well formed numeric value encountered in /home/ghadeerr/public_html/ on line 118

Ecwid has a very nice project on github that wraps mailchimp’s API in Java.

Let’s cover two basic examples. If you understand how these two examples work, all of the other API calls you may want to leverage will be pretty straight forward.

The first thing we need to do is import the ecwid-mailchimp library into our Java project with maven.

The library has broken up the mailchimp API into two main parts; Methods, and MethodResults. Methodaa are executed and MethodResults are returned. Let’s have a deeper look with an example.

Let’s call mailchimp’s list api. To do this, we will call a class called ListMethod and then extract the results which will be provided in the wrapper class ListMethodResult.

Now that we have executed the method, we can print a list of all of the ids

Below is another example. We will unsubscribe a user from a given list. Again, we call an UnsubscribeMethod, and then get the result in a class called: DummyResult.

You can find a sample project here: github.

I hope this example has shed some light on how to use Mailchimp with Java. For a NodeJS mailchimp example, you can reference this post

If you enjoyed this article, enter your email below to get free updates!