-
Notifications
You must be signed in to change notification settings - Fork 17
/
check_removed_apis.php
59 lines (44 loc) · 1.3 KB
/
check_removed_apis.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
58
59
<?php
$FinalList = json_decode( file_get_contents( __DIR__ . '/api.json' ), true, 512, JSON_THROW_ON_ERROR );
$c = curl_init( );
curl_setopt_array( $c, [
CURLOPT_USERAGENT => '',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 5,
CURLOPT_CONNECTTIMEOUT => 5,
] );
$notFound = "<html>\n<head>\n<title>404 Not Found</title>\n</head>\n<body>\n<h1>Not Found</h1>\n</body>\n</html>";
$copy = $FinalList;
foreach( $copy as $serviceName => $Interface )
{
foreach( $Interface as $methodName => $Method )
{
$path = $serviceName . '/' . $methodName . '/v' . $Method[ 'version' ];
printf( 'Checking %-70s', $path . '...' );
curl_setopt( $c, CURLOPT_URL, "https://api.steampowered.com/{$path}/" );
$response = curl_exec( $c );
$code = curl_getinfo( $c, CURLINFO_HTTP_CODE );
echo ' ' . $code;
if( $code !== 404 )
{
echo PHP_EOL;
continue;
}
if( $response !== $notFound )
{
echo ' different kind of error' . PHP_EOL;
continue;
}
echo ' REMOVED!' . PHP_EOL;
unset( $FinalList[ $serviceName ][ $methodName ] );
}
if( empty( $FinalList[ $serviceName ] ) )
{
unset( $FinalList[ $serviceName ] );
}
}
file_put_contents(
__DIR__ . DIRECTORY_SEPARATOR . 'api.json',
json_encode( $FinalList, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) . PHP_EOL
);
echo 'Done' . PHP_EOL;