Java

white

Java API

The best way to use the Red Oxygen API from Java is to use the HTTP interface.

Example

public static int SendSMS(String AccountID, String Email, String Password,
String Recipient, String Message, StringBuffer Response)
{
	String RequestURL = "http://www.redoxygen.net/sms.dll?Action=SendSMS";
 
	String Data = ("AccountId=" + URLEncoder.encode(AccountID, "UTF-8"));
	Data += ("&Email=" + URLEncoder.encode(Email, "UTF-8"));
	Data += ("&Password=" + URLEncoder.encode(Password, "UTF-8"));
	Data += ("&Recipient=" + URLEncoder.encode(Recipient, "UTF-8"));
	Data += ("&Message=" + URLEncoder.encode(Message, "UTF-8"));
 
	int Result = -1;
	URL Address = new URL(RequestURL);
 
	HttpURLConnection Connection = (HttpURLConnection) Address.openConnection();
	Connection.setRequestMethod("POST");
	Connection.setDoInput(true);
	Connection.setDoOutput(true);
 
	DataOutputStream Output;
	Output = new DataOutputStream(Connection.getOutputStream());
	Output.writeBytes(Data);
	Output.flush();
	Output.close();
 
	BufferedReader Input = new BufferedReader(new InputStreamReader(Connection.getInputStream()));
	StringBuffer ResponseBuffer = new StringBuffer();
	String InputLine;
 
	while ((InputLine = Input.readLine()) != null)
	{
		ResponseBuffer = ResponseBuffer.append(InputLine);
		ResponseBuffer = ResponseBuffer.append("\n\n\n");
	}
 
	Response.replace(0, 0, ResponseBuffer.toString());
	String ResultCode = Response.substring(0, 4);
	Result = Integer.parseInt(ResultCode);
	Input.close();
 
	return Result;
}

Properties

Name Type Description Example
AccountId String This is your Red Oxygen Account ID, which uniquely identifies your account. CI00000001
Email String This is the email address of your Red Oxygen user account. It is also the address that will receive replies to the sent SMS. username@company.com
Password String This is the password of your Red Oxygen user account. secret
Recipient String The destination mobile numbers. Multiple recipients can be specified comma separated. 61409000000,61419718927,61419718972
Message String A single SMS has a maximum length of 160 characters. If the message is greater than 160 characters then multiple SMS will be sent as a concatenated SMS which will result in an additional charge for the additional messages. The maximum length of a message is 765 characters. If you exceed this limit only the first 765 characters of your message will be sent. Server 23 is offline.

For more details see the Red Oxygen API HTTP User Guide.

Want us to set it up for you?

Get in touch with our team and we will get back to you as soon as possible!

    white