forked from php/web-qa
-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.php
58 lines (47 loc) · 1.37 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
57
<?php
require 'include/release-qa.php';
require 'include/functions.php';
$TITLE = "QA API";
$SITE_UPDATE = date("D M d H:i:s Y T", filectime(__FILE__));
$types = array('qa-releases');
$formats = array('serialize', 'json');
if (empty($QA_RELEASES)) {
die('Major Fail: $QA_RELEASES is empty.');
}
if (!empty($_GET['type'])) {
if (!empty($_GET['only']) && $_GET['only'] === 'dev_versions') {
$output = $QA_RELEASES['reported'];
} else {
$output = $QA_RELEASES;
}
$format = 'serialize';
if (in_array($_GET['type'], $types)) {
if (isset($_GET['format']) && in_array($_GET['format'], $formats)) {
$format = $_GET['format'];
}
switch ($format) {
case 'json':
echo json_encode($output);
break;
case 'serialize':
echo serialize($output);
break;
}
exit;
}
}
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">http://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">http://qa.php.net/api.php?type=qa-releases&format=json&only=dev_versions</a></li>
</ul>
<?php
common_footer();
?>