Skip to content

Instantly share code, notes, and snippets.

@IbrahimTareq
Created May 12, 2018 00:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save IbrahimTareq/65068b3d6f3a6d7e8708ca70e933d7aa to your computer and use it in GitHub Desktop.
Save IbrahimTareq/65068b3d6f3a6d7e8708ca70e933d7aa to your computer and use it in GitHub Desktop.
MessageMedia Messages Java
package com.company;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.messagemedia.messages.MessageMediaMessagesClient;
import com.messagemedia.messages.controllers.MessagesController;
import com.messagemedia.messages.models.SendMessagesRequest;
import com.fasterxml.jackson.core.type.TypeReference;
public class Main {
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 bodyValue = "{\"messages\":" +
"[{\"content\":\"My first message\", " +
"\"destination_number\":\"+61491570156\"" +
"}]}";
SendMessagesRequest request = new SendMessagesRequest();
ObjectMapper mapper = new ObjectMapper();
SendMessagesRequest body = mapper.readValue(bodyValue,new TypeReference<SendMessagesRequest> (){});
messages.createSendMessages(body);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment