forked from iamcal/oembed
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjson.php
43 lines (31 loc) · 761 Bytes
/
json.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
<?php
header('Content-type: text/plain; charset=utf-8');
#
# gather providers from the various files
#
$data = array();
$dh = opendir('providers');
while (($file = readdir($dh)) !== false){
if (preg_match('!\.yml$!', $file)){
$partial = yaml_parse_file("providers/$file");
foreach ($partial as $row) $data[] = $row;
}
}
#
# scrub some fields
#
foreach ($data as &$provider){
foreach ($provider['endpoints'] as &$endpoint){
unset($endpoint['docs_url']);
unset($endpoint['example_urls']);
unset($endpoint['notes']);
}
}
#
# sort and output
#
usort($data, 'local_sort');
function local_sort($a, $b){
return strcasecmp($a['provider_name'], $b['provider_name']);
}
echo json_encode($data, JSON_PRETTY_PRINT);