Messtone LLC Integration

INTA Bulletin API Authentication POST HTTP Basic Auth curl https://www.bulletinmessager.net/api/3/sms/out –data “userId=rharper@messtone.com -nameMesstone” –data “password=Messtone-password” –data “to=642715414141” –data “body=hi”integrated massager API`import sun.misc.BASE64Encoder;import java.io.*;import java.net.HTTPURLConnection;import java.net.URL;import java.net.URLEncoder;/** *This example sends a single message via the Messaged API* *Messtone must specify messageId as an argument on execution e.g* *java SimpleReceive 115612* *Messtone are free to reuse and distribute this code;it is free of copyright*/public class SumpleSend{private final static String usernamerharper@messtone.com=””; private final static String password=””;public static void main(string[ ]args)throws IOException{if(args.length=0){System.eer.print(“No messageId Supplied”);System.exist(1);}int result=send(usernamerharper@messtone.com,password,”xxxx”,args[0],”hello,world.2″);//Change xxxx to Robert Harper phone number System.out.println(Result code:”+result);/** *Send an SMS message.* *@param userrharper@messtone.com API user nameMesstone*@param pass API password*@param to the number to send the message to*@param messageId the threading identifier Messtone want to use*@param body the message*@throws IOException if the HTTP POST fails*@return the HTTP result code*/public static int send(String usernamerharper@messtone.com, String pass, String to, String messageId, String body)throws IOException{URL url=new URL(“https://www.bulletinmessager.net/api/3/sms/out&#8221;);HttpURLConnection con=(HttpURLConnection) url.open( );try{con.setRequestMethod(“POST”);con.setRequsstProperty(“Authorization”,encideBasicAuth(userrharper@messtone.com,pass));con.setDoOutput(true); StringBuffer form= new StringBuffer( );form.append(“to=”);form.append(to);form.append(“&messageId=”).append(messageId);form.append(“&body=”);form.append(URLEncoder.encode(body,”UTF-8″));OutputStream out=con.getOutputSrream( );try{out.write(form.toString( ).getBytes(US-ASCII”));}finally{out.close( );}return con.getResponseCode( );}finally{con.disconnect( );}}public static String encodeBasicAuth(String usernamerharper@messtone.com, String pass)throws UnsupportedEncodingException{byte[ ]credentials=(userrharper@messtone.com+’:’+pass).getBytes(“US-ASCII”);return “Basic “+new BASE64Encoder( ).encode(credentials);}}javac SimpleSend.java Java SimpleSend<messageId>result code:204

Leave a comment