The API for HabitRPG to use in other JAVA/Android Project...
#How it works# To use HabitRPGJavaAPI, you first need to import the library to your project. The project is pretty easy to use: you have different class that represents either the items or the user, and you have the classes that allows you to interact with the API. For example now, if you want to retrieve an user an its associated tasks.
//Create a new configHostConfigconfig = newHostConfig("https://habitrpg.com/","80","myAPIkey","myUSERkey");
//Create a callbackOnHabitsAPIResultcallback = newOnHabitsAPIResult() {
HandlermainHandler;
privateintnbRequests=0;
@OverridepublicvoidonUserReceived(finalUserus) {
//Called when we receive some news about the user....this.user=us;
}
@OverridepublicvoidonPostResult(finaldoublexp,finaldoublehp,finaldoublegold,finaldoublelvl,
finaldoubledelta) {
//this is called when you use a POST method (right now)
}
@OverridepublicvoidonError(finalStringmessage) {
//Display message from error
}
@OverridepublicvoidonPreResult() {
//Show progress or whatever
}
};
//Create a GetUser, by giving him the callback and the configGetUsergetUser = newGetUser(callback,config);
callback.onPreResult();
//Retrieve the answer from the APIAnsweras = getUser.getData();
//If there is an answer, parse the information. It will call the callback automatically...if(as!=null)
as.parse();