Created
May 12, 2018 00:54
-
-
Save IbrahimTareq/65068b3d6f3a6d7e8708ca70e933d7aa to your computer and use it in GitHub Desktop.
MessageMedia Messages Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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