Skip to end of metadata
Go to start of metadata

In this example we will perform the steps to retrieve a schedule. This can be used to get your own schedule in JSON format.

Prerequisites

  • A username and password for a Zermelo Portal.
  • The user needs to have a schedule in the Zermelo Portal.
  • The user needs to have permissions to see his schedule.
  • Some experience with JSON.
  • Some experience with Curl.

Step 1: The authorization code

We log in to the Portal using our username and password. Our Portal is example.zportal.nl in this walk through.Then we we go to the "Koppel App" (Link App) page and note the authorization code. In this example it is 120 340 450 670.

For more information about this step see API Authentication.

Step 2: The access token

We now use the authorization code to retrieve an access token.

$ curl --data "grant_type=authorization_code&code=120340450670" https://example.zportal.nl/api/v3/oauth/token

Curl will print out the following:

{
    "access_token":"gmj5if8aqcute3n0evi6g3uaee",
    "token_type":"bearer",
    "expires_in":57600
}

Here gmj5if8aqcute3n0evi6g3uaee is our access token.

For more information about this step see Exchange the authorization code for an access token.

Known bug: the "expires_in" value returned may not be correct.


Step 3: The schedule

We can now use this access token to retrieve our schedule. The start and end parameters are in Unix time.

$ curl "https://example.zportal.nl/api/v3/appointments?user=~me&start=1388998982&end=1389998982&access_token=gmj5if8aqcute3n0evi6g3uaee"

This is the response:

{
  "response": {
    "status":200,
    "message":"",
    "startRow":0,
    "endRow":27,
    "totalRows":27,
    "data":[
      {
        "id":5,
        "start":42364236,
        "end":436234523,
        "startTimeSlot": 1,
        "endTimeSlot": 1,
        "subjects":["ne"],
        "teachers":["KRO"],
        "groups":["v1a"],
        "locations":["M92"],
        "type":"lesson",
        "remark":"Take care to bring your books",
        "valid":true,
        "cancelled":false,
        "modified":true,
        "moved":false,
        "new":false,
        "changeDescription":"The location has been changed from M13 to M92"
      },
      ...
    ]
  }
}

For more information about this step see Appointment.

  • No labels