testtongji.php代码如下
<?php error_reporting(0);
$url = 'https://www.zzxxxx.xx/api /wetds/stats/';
$options = array(
'http' => array(
'header' => "Content-Type: application/json",
'header' => "Authorization: Token 633b4deb1cd517a01851a3335811b9ae8e1d6d6d",
'method' => 'GET',
'content' => http_build_query
)
);
$context = stream_context_create($options);
$result = file_get_contents($ url, false, $context);
echo ($result);
打开testtongji.php 返される回数次のような
{"使用帯域幅":393073846353、"帯域幅残り":680667977647.0、"帯域幅制限":1073741824000.0、"帯域幅投影":1496203172977、"最終要求_at":"2021-01-13T01:59:3 8.381732-08:00 ","requests_total":239278,"requests_成功":238115,"requests_failed":1163,"request_countries":{"US":238334,"NL":848,"RS":96},"requests_error_reasons":{" target_read_deadline":1142,"target_connect_timeout":12,"client_read_timeout":2,"client_read_eof":7},"request_failure_status_codes":{}}
echo ($result);整理次のように
必要な以上の返されるデータを以下の内容に整理します。このような展示、その他データ都不要
既用流量: XXXX GB
剩余流量: XXXX GB