-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapi.php
More file actions
23 lines (19 loc) · 805 Bytes
/
api.php
File metadata and controls
23 lines (19 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
// Fetches recent programming-contest data from the clist.by API.
//
// Configuration: set the following environment variables before running.
// Get an API key at https://clist.by/ (account settings).
//
// CLIST_USERNAME your clist.by username
// CLIST_API_KEY your clist.by API key
$clist_username = getenv('CLIST_USERNAME') ?: '';
$clist_api_key = getenv('CLIST_API_KEY') ?: '';
if ($clist_username === '' || $clist_api_key === '') {
die("Error: set CLIST_USERNAME and CLIST_API_KEY environment variables.\n");
}
$api_url = "https://clist.by:443/api/v1/contest/?username=" . urlencode($clist_username)
. "&api_key=" . urlencode($clist_api_key)
. "&order_by=-id";
$contest = json_decode(file_get_contents($api_url));
$first_duration = $contest->meta->limit;
?>