-
Notifications
You must be signed in to change notification settings - Fork 39
/
api.php
56 lines (50 loc) · 1.52 KB
/
api.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
// Attempt to handle an API request of either following forms:
// api.php?type=qa-releases
// api.php?type=qa-releases&format=json
// api.php?type=qa-releases&format=serialize
//
// Missing format specifier will default to 'serialize'
// Output HTML help if type arg is missing or invalid.
(function() {
require 'include/release-qa.php';
!empty($QA_RELEASES) or die('Major Fail: $QA_RELEASES is empty.');
switch ($_GET['type'] ?? null) {
case 'qa-releases':
$output = $QA_RELEASES;
if (($_GET['only'] ?? null) === 'dev_versions') {
$output = $output['reported'];
}
break;
default:
return;
}
switch ($_GET['format'] ?? null) {
case 'json':
echo json_encode($output);
exit;
case 'serialize':
default:
echo serialize($output);
exit;
}
})();
// Fallback on presenting documentation for this script.
require 'include/functions.php';
$TITLE = "QA API";
$SITE_UPDATE = date("D M d H:i:s Y T", filectime(__FILE__));
common_header();
?>
<p>
The QA API is simple, and is based on the query string.
Pass in type=qa-releases (the only type currently), along with the desired format (serialize or json).
</p>
<p>
Example URLs:
<ul>
<li>All information, serialized: <a href="api.php?type=qa-releases&format=serialize">https://qa.php.net/api.php?type=qa-releases&format=serialize</a></li>
<li>Only dev version numbers, json: <a href="api.php?type=qa-releases&format=json&only=dev_versions">https://qa.php.net/api.php?type=qa-releases&format=json&only=dev_versions</a></li>
</ul>
</p>
<?php
common_footer();