An easy to use API to implement Zermelo schedules into your app. developed by Jules Hummelink.
- Import the ZermeloAPI.jar into your project.
- Make sure you add it to your project dependencies.
First of all, we will create the ZermeloAPI object.
ZermeloAPI zermeloHelper;
Now set the object in onCreate:
@Override
protected void onCreate(Bundle savedInstanceState) {
zermeloHelper = new ZermeloAPI();
}
Now make sure, you have the school and the AuthCode from the user as Strings:
String school = "testSchool";
String code = "123456789123";
Now start the API:
zermeloHelper.start(school);
It is recommended to run the following commands in an AsyncTask, but for this tutorial, let's enable running network requests on the main thread (only in Android Studio. Use what is supported for your platform):
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Then finally, get the token by running the following command:
String token = zermeloHelper.getToken(code);
Store the token and school for later use!
First define a start and end time in UNIX time, and you will also need the school and a token:
long startTime = 1543357871;
long endTime = 154347839;
String token = "testToken";
String school = "testSchool";
ZermeloAPI zermeloHelper;
Now set the ZermeloAPI object in onCreate:
@Override
protected void onCreate(Bundle savedInstanceState) {
zermeloHelper = new ZermeloAPI();
}
Now start the API:
zermeloHelper.start(school);
It is recommended to run the following commands in an AsyncTask, but for this tutorial, let's enable running network requests on the main thread (only in Android Studio, use what is supported for your platform):
StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
Now finally get a List by using:
List<Appointment> appointments = zermeloHelper.getAppointments(startTime, endTime, token);
For example if you want the subject use:
Appointment appointment = appointments.get(0);
String subject = appointment.getSubject()[0];
If an appointment has multiple subjects, locations, groups or teachers, it works like this:
String subject1 = appointment.getSubject()[0];
String subject2 = appointment.getSubject()[1];