I’m new to the Zipwhip API so I figured I would share my experience sending out my first text message using the Zipwhip system. To follow along with this article you will need to get your hands on the Zipwhip API as a JAR file. It’s available here for download:

Zipwhip API Jar File (170KB) ZipwhipAPI.jar

Release Date: 6/18/2011

First, open up Eclipse and make a new Java project.

image

image

Call the project ZipwhipAPIExample. (BTW, you can zoom in on the screenshots by clicking them.)

image

You can leave the Source tab alone, however you will want to add the ZipwhipAPI Jar to the Libraries tab.

image

Make sure you download the ZipwhipAPI Jar from the link at the start of this article. Then, add it to the Libraries list by choosing “Add External JARs” and finding the file on your local computer. Make sure to add the Log4J Jar file as well since the ZipwhipAPI is dependant upon it. You will get compile errors if you don’t have Log4J somewhere in the build path.

image

You should now have a new project in your Package Explorer. You are ready to go.

image

Make a new Java class file by right-clicking the src folder and choosing “Class”.

image

Call your class “Example” after you’ve entered a package name of something like “com.yourcompany.zipwhipapi”. Make sure to also create a public static void main() method so you have an entry point for your Java app.

image

After you hit “Finish” you should see something similar to the following generated code.

image

Now, we’ll help you out with the code you should place into the Example.java file in order to send off your first text message using the Zipwhip API. Make sure you set your own mobile number and password in the code. If you don’t know what your password is, or you have never signed up for Zipwhip, you need to do it via your carrier website if your carrier supports Zipwhip. Zipwhip has contracts with most major U.S. carriers so please visit your carrier site or call your carrier to find out how to gain access.

Download source code below Example.java

 1: package com.yourcompany.zipwhipapi;
 2:
 3: import com.zipwhip.api.DefaultZipwhipClient;
 4: import com.zipwhip.api.HttpConnection;
 5: import com.zipwhip.api.ZipwhipClient;
 6:
 7: public class Example {
 8:
 9:     public static void main(String[] args) {
 10:
 11:         HttpConnection connection = new HttpConnection();
 12:
 13:         String mobileNumber = "3135551212";
 14:         String password = "mypassword";
 15:
 16:         try {
 17:             connection.requestLogin(mobileNumber, password);
 18:             ZipwhipClient zipwhipClient = new DefaultZipwhipClient(connection);


 

 21:             zipwhipClient.sendMessage("3134440002", "This is our first test SMS message.");
 22:
 23:             System.out.println("Done sending message");
 24:
 25:         } catch (Exception e) {
 26:             // TODO Auto-generated catch block
 27:             e.printStackTrace();
 28:         }
 29:     }
 30: }

This is what your Eclipse window should look like when all of the code is done and ready to go.

image

That’s it. Have fun sending off text messages via Zipwhip’s spectacularly simple API. If you want to get fancy, try to use some of the other methods in the API that let you create contacts, create groups, receive messages back, let you setup a URL to be posted to when an SMS comes in, etc.

To learn how to receive text messages via the Zipwhip API you can read my next posting.

zipwhip

Zipwhip is the productivity tool that lets businesses and customers text each other like friends. Zipwhip text-enables your existing (landline, VoIP, or toll free) business number. With direct connections to tier 1 carriers - Zipwhip is the trusted, scalable solution to business texting.

Join our newsletter
Get the latest business texting news directly in your inbox.