package com.panaceamobile;
import org.json.JSONObject;
public class ApiExample {
/**
* @param args
*/
public static void main(String[] args) {
Api api = new Api("demouser", "demouser");
api.setDebugging(false);
String message_id = api.message_send("0832659217", "Hi there, I just sent a message!", "0214224825", null, null, null, null); /* Not all arguments are required */
if(message_id != null) {
System.out.println("It worked! Your message was sent!");
/* Now we can do some other checks */
Double balance = api.user_get_balance();
if(balance != null) {
System.out.println("Great! My balance is "+balance.toString());
}
JSONObject status = api.message_status(message_id);
if(status != null) {
try {
System.out.println("Message cost was "+String.valueOf(status.getDouble("cost")));
System.out.println("Message status is now "+String.valueOf(status.getInt("status")));
System.out.println("Message had "+String.valueOf(status.getInt("parts")) + " parts");
} catch(Exception e) {
System.out.println("JSON Error");
e.printStackTrace();
}
}
} else {
System.out.println("Could not send message :(");
}
}
}