MessageMedia Messages SDK

Snapshot with unirest in it

License

License

GroupId

GroupId

com.messagemedia.sdk
ArtifactId

ArtifactId

messagesbundle
Last Version

Last Version

1.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

MessageMedia Messages SDK
Snapshot with unirest in it
Project URL

Project URL

https://github.com/messagemedia/messages-java-sdk
Project Organization

Project Organization

MessageMedia
Source Code Management

Source Code Management

https://github.com/messagemedia/messages-java-sdk

Download messagesbundle

How to add to project

<!-- https://jarcasting.com/artifacts/com.messagemedia.sdk/messagesbundle/ -->
<dependency>
    <groupId>com.messagemedia.sdk</groupId>
    <artifactId>messagesbundle</artifactId>
    <version>1.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.messagemedia.sdk/messagesbundle/
implementation 'com.messagemedia.sdk:messagesbundle:1.0.1'
// https://jarcasting.com/artifacts/com.messagemedia.sdk/messagesbundle/
implementation ("com.messagemedia.sdk:messagesbundle:1.0.1")
'com.messagemedia.sdk:messagesbundle:jar:1.0.1'
<dependency org="com.messagemedia.sdk" name="messagesbundle" rev="1.0.1">
  <artifact name="messagesbundle" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.messagemedia.sdk', module='messagesbundle', version='1.0.1')
)
libraryDependencies += "com.messagemedia.sdk" % "messagesbundle" % "1.0.1"
[com.messagemedia.sdk/messagesbundle "1.0.1"]

Dependencies

compile (8)

Group / Artifact Type Version
com.fasterxml.jackson.core : jackson-databind jar 2.2.3
com.fasterxml.jackson.core : jackson-core jar 2.2.3
com.fasterxml.jackson.core : jackson-annotations jar 2.2.3
org.apache.httpcomponents : httpasyncclient jar 4.0.1
org.apache.httpcomponents : httpclient jar 4.3.4
org.apache.httpcomponents : httpcore jar 4.3.2
org.apache.httpcomponents : httpmime jar 4.3.4
org.apache.httpcomponents : httpcore-nio jar 4.3.2

test (1)

Group / Artifact Type Version
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

MessageMedia Messages Java SDK

Pull Requests Welcome maven

The MessageMedia Messages API provides a number of endpoints for building powerful two-way messaging applications.

Isometric

Table of Contents

๐Ÿ” Authentication

Authentication is done via API keys. Sign up at https://developers.messagemedia.com/register/ to get your API keys.

Requests are authenticated using HTTP Basic Auth or HMAC. Provide your API key as the auth_user_name and API secret as the auth_password.

โ‰๏ธ Errors

Our API returns standard HTTP success or error status codes. For errors, we will also include extra information about what went wrong encoded in the response as JSON. The most common status codes are listed below.

HTTP Status Codes

Code Title Description
400 Invalid Request The request was invalid
401 Unauthorized Your API credentials are invalid
403 Disabled feature Feature not enabled
404 Not Found The resource does not exist
50X Internal Server Error An error occurred with our API

๐Ÿ“ฐ Information

Slack and Mailing List

If you have any questions, comments, or concerns, please join our Slack channel: https://developers.messagemedia.com/collaborate/slack/

Alternatively you can email us at: [email protected]

Bug reports

If you discover a problem with the SDK, we would like to know about it. You can raise an issue or send an email to: [email protected]

Contributing

We welcome your thoughts on how we could best provide you with SDKs that would simplify how you consume our services in your application. You can fork and create pull requests for any features you would like to see or raise an issue

โญ Installation

At present the jars are available from a public maven repository.

Use the following dependency in your project to grab via Maven:

<dependency>
  <groupId>com.messagemedia.sdk</groupId>
  <artifactId>messages</artifactId>
  <version>2.0.0</version>
</dependency>

๐ŸŽฌ Get Started

It's easy to get started. Simply enter the API Key and secret you obtained from the MessageMedia Developers Portal into the code snippet below and a mobile number you wish to send to.

Send an SMS

Destination numbers (destination_number) should be in the E.164 format. For example, +61491570156.

import java.util.ArrayList;
import java.util.List;

import com.messagemedia.messages.MessageMediaMessagesClient;
import com.messagemedia.messages.controllers.MessagesController;
import com.messagemedia.messages.http.client.APICallBack;
import com.messagemedia.messages.http.client.HttpContext;
import com.messagemedia.messages.models.Message;
import com.messagemedia.messages.models.SendMessagesRequest;
import com.messagemedia.messages.models.SendMessagesResponse;

public class App
{
    public static void main( String[] args )
    {

     // Configuration parameters and credentials
        String authUserName = "API_KEY"; // The username to use with basic/HMAC authentication
        String authPassword = "API_SECRET"; // The password to use with basic/HMAC authentication
        boolean useHmacAuth = false; // Change to true if you are using HMAC keys

        MessageMediaMessagesClient client = new MessageMediaMessagesClient(authUserName, authPassword, useHmacAuth);
        MessagesController messages = client.getMessages();

        Message message = new Message();
        message.setContent("My message");
        message.setDestinationNumber("+61466412529");

        List<Message> messagesList = new ArrayList<Message>();
        messagesList.add(message);

        SendMessagesRequest body = new SendMessagesRequest();
        body.setMessages(messagesList);

        messages.sendMessagesAsync(body, new APICallBack<SendMessagesResponse>() {
		        public void onSuccess(HttpContext context, SendMessagesResponse response) {
		            // TODO success callback handler
		        	System.out.println("success");
		        }
		        public void onFailure(HttpContext context, Throwable error) {
		            // TODO failure callback handler
		        	System.out.println("failure");
		        }
			});
    }
}

Send an MMS

  • Destination numbers (destination_number) should be in the E.164 format. For example, +61491570156.
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import com.messagemedia.messages.MessageMediaMessagesClient;
import com.messagemedia.messages.controllers.MessagesController;
import com.messagemedia.messages.http.client.APICallBack;
import com.messagemedia.messages.http.client.HttpContext;
import com.messagemedia.messages.models.FormatEnum;
import com.messagemedia.messages.models.Message;
import com.messagemedia.messages.models.SendMessagesRequest;
import com.messagemedia.messages.models.SendMessagesResponse;

public class App
{
    public static void main( String[] args )
    {

     // Configuration parameters and credentials
        String authUserName = "API_KEY"; // The username to use with basic/HMAC authentication
        String authPassword = "API_SECRET"; // The password to use with basic/HMAC authentication
        boolean useHmacAuth = false; // Change to true if you are using HMAC keys

        MessageMediaMessagesClient client = new MessageMediaMessagesClient(authUserName, authPassword, useHmacAuth);
        MessagesController messages = client.getMessages();

        Message message = new Message();
        message.setContent("My message");
        message.setDestinationNumber("+61466412529");
        message.setFormat(FormatEnum.MMS);
        message.setSubject("This is an MMS");
        message.setMedia(new ArrayList<String>(Arrays.asList("https://upload.wikimedia.org/wikipedia/commons/6/6a/L80385-flash-superhero-logo-1544.png")));


        List<Message> messagesList = new ArrayList<Message>();
        messagesList.add(message);

        SendMessagesRequest body = new SendMessagesRequest();
        body.setMessages(messagesList);

        messages.sendMessagesAsync(body, new APICallBack<SendMessagesResponse>() {
		        public void onSuccess(HttpContext context, SendMessagesResponse response) {
		            // TODO success callback handler
		        	System.out.println("success");
		        }
		        public void onFailure(HttpContext context, Throwable error) {
		            // TODO failure callback handler
		        	System.out.println("failure");
		        }
			});
    }
}

Get Status of a Message

You can get a messsage ID from a sent message by looking at the message_id from the response of the above example.

import com.messagemedia.messages.MessageMediaMessagesClient;
import com.messagemedia.messages.controllers.MessagesController;
import com.messagemedia.messages.http.client.APICallBack;
import com.messagemedia.messages.http.client.HttpContext;
import com.messagemedia.messages.models.GetMessageStatusResponse;

public class App {

    public static void main(String[] args) throws Throwable {
        // Configuration parameters and credentials
        String authUserName = "API_KEY"; // The username to use with basic/HMAC authentication
        String authPassword = "API_SECRET"; // The password to use with basic/HMAC authentication
        boolean useHmacAuth = false; // Change to true if you are using HMAC keys

        MessageMediaMessagesClient client = new MessageMediaMessagesClient(authUserName, authPassword, useHmacAuth);
        MessagesController messages = client.getMessages();

        String messageId = "YOUR_MESSAGE_ID";
        messages.getMessageStatusAsync(messageId, new APICallBack<GetMessageStatusResponse>() {
	        public void onSuccess(HttpContext context, GetMessageStatusResponse response) {
	            // TODO success callback handler
	        	System.out.println("success");
	        }
	        public void onFailure(HttpContext context, Throwable error) {
	            // TODO failure callback handler
	        	System.out.println("failure");
	        }
		});
    }

}

Get replies to a message

You can check for replies that are sent to your messages

import com.messagemedia.messages.MessageMediaMessagesClient;
import com.messagemedia.messages.controllers.MessagesController;
import com.messagemedia.messages.controllers.RepliesController;
import com.messagemedia.messages.http.client.APICallBack;
import com.messagemedia.messages.http.client.HttpContext;
import com.messagemedia.messages.models.CheckRepliesResponse;
import com.messagemedia.messages.models.GetMessageStatusResponse;

public class App {

    public static void main(String[] args) throws Throwable {
        // Configuration parameters and credentials
        String authUserName = "API_KEY"; // The username to use with basic/HMAC authentication
        String authPassword = "API_SECRET"; // The password to use with basic/HMAC authentication
        boolean useHmacAuth = false; // Change to true if you are using HMAC keys

        MessageMediaMessagesClient client = new MessageMediaMessagesClient(authUserName, authPassword, useHmacAuth);
        RepliesController replies = client.getReplies();

        replies.checkRepliesAsync(new APICallBack<CheckRepliesResponse>() {
	        public void onSuccess(HttpContext context, CheckRepliesResponse response) {
	            // TODO success callback handler
	        	System.out.println("success");
	        }
	        public void onFailure(HttpContext context, Throwable error) {
	            // TODO failure callback handler
	        	System.out.println("failure");
	        }
		});  

    }

}

Check Delivery Reports

This endpoint allows you to check for delivery reports to inbound and outbound messages.

import com.messagemedia.messages.MessageMediaMessagesClient;
import com.messagemedia.messages.controllers.DeliveryReportsController;
import com.messagemedia.messages.http.client.APICallBack;
import com.messagemedia.messages.http.client.HttpContext;
import com.messagemedia.messages.models.CheckDeliveryReportsResponse;


public class App
{
    public static void main( String[] args )
    {

     // Configuration parameters and credentials
        String authUserName = "API_KEY"; // The username to use with basic/HMAC authentication
        String authPassword = "API_SECRET"; // The password to use with basic/HMAC authentication
        boolean useHmacAuth = false; // Change to true if you are using HMAC keys

        MessageMediaMessagesClient client = new MessageMediaMessagesClient(authUserName, authPassword, useHmacAuth);
        DeliveryReportsController deliveryReports = client.getDeliveryReports();

        deliveryReports.checkDeliveryReportsAsync(new APICallBack<CheckDeliveryReportsResponse>() {
		        public void onSuccess(HttpContext context, CheckDeliveryReportsResponse response) {
		            // TODO success callback handler
		        	System.out.println("success");
		        }
		        public void onFailure(HttpContext context, Throwable error) {
		            // TODO failure callback handler
		        	System.out.println("failure");
		        }
			});
    }
}

Confirm Delivery Reports

This endpoint allows you to mark delivery reports as confirmed so they're no longer returned by the Check Delivery Reports function.

import java.util.ArrayList;
import java.util.List;

import com.messagemedia.messages.MessageMediaMessagesClient;
import com.messagemedia.messages.controllers.DeliveryReportsController;
import com.messagemedia.messages.http.client.APICallBack;
import com.messagemedia.messages.http.client.HttpContext;
import com.messagemedia.messages.models.CheckDeliveryReportsResponse;
import com.messagemedia.messages.models.ConfirmDeliveryReportsAsReceivedRequest;
import com.messagemedia.messages.models.DynamicResponse;


public class App
{
    public static void main( String[] args )
    {

     // Configuration parameters and credentials
        String authUserName = "API_KEY"; // The username to use with basic/HMAC authentication
        String authPassword = "API_SECRET"; // The password to use with basic/HMAC authentication
        boolean useHmacAuth = false; // Change to true if you are using HMAC keys

        MessageMediaMessagesClient client = new MessageMediaMessagesClient(authUserName, authPassword, useHmacAuth);
        DeliveryReportsController deliveryReports = client.getDeliveryReports();

        ConfirmDeliveryReportsAsReceivedRequest body = new ConfirmDeliveryReportsAsReceivedRequest();
        List<String> reportIds = new ArrayList<String>();
        reportIds.add("delivery-report-id");

        deliveryReports.confirmDeliveryReportsAsReceivedAsync(body, new APICallBack<DynamicResponse>() {
		        public void onSuccess(HttpContext context, DynamicResponse response) {
		            // TODO success callback handler
		        	System.out.println("success");
		        }
		        public void onFailure(HttpContext context, Throwable error) {
		            // TODO failure callback handler
		        	System.out.println("failure");
		        }
			});
    }
}

Check credits remaining (Prepaid accounts only)

This endpoint allows you to check for credits remaining on your prepaid account.

import com.messagemedia.messages.MessageMediaMessagesClient;
import com.messagemedia.messages.controllers.MessagesController;
import com.messagemedia.messages.http.client.APICallBack;
import com.messagemedia.messages.http.client.HttpContext;
import com.messagemedia.messages.models.DynamicResponse;


public class App
{
    public static void main( String[] args )
    {

     // Configuration parameters and credentials
        String authUserName = "API_KEY"; // The username to use with basic/HMAC authentication
        String authPassword = "API_SECRET"; // The password to use with basic/HMAC authentication
        boolean useHmacAuth = false; // Change to true if you are using HMAC keys

        MessageMediaMessagesClient client = new MessageMediaMessagesClient(authUserName, authPassword, useHmacAuth);
        MessagesController messages = client.getMessages();
        
        messages.checkCreditsRemainingAsync(new APICallBack<DynamicResponse>() {
		        public void onSuccess(HttpContext context, DynamicResponse response) {
		            // TODO success callback handler
		        	System.out.println(response.toString());
		        }
		        public void onFailure(HttpContext context, Throwable error) {
		            // TODO failure callback handler
		        	System.out.println("failure");
		        }
			});
    }
}

๐Ÿ“• API Reference Documentation

Check out the full API documentation for more detailed information.

๐Ÿ˜• Need help?

Please contact developer support at [email protected] or check out the developer portal at developers.messagemedia.com

๐Ÿ“ƒ License

Apache License. See the LICENSE file.

com.messagemedia.sdk

MessageMedia

Business SMS messaging. And so much more.

Versions

Version
1.0.1