testtongji.php 代碼返回數(shù)據(jù)整理最后想要的結(jié)果
問題描述
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 返回數(shù)據(jù)如下
{"bandwidth_used":393073846353,"bandwidth_remaining":680667977647.0,"bandwidth_limit":1073741824000.0,"bandwidth_projected":1496203172977,"last_request_at":"2021-01-13T01:59:38.381732-08:00","requests_total":239278,"requests_successful":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);整理如下
需要把以上返回的數(shù)據(jù)整理為以下內(nèi)容 bandwidth_used":393073846353,"bandwidth_remaining":680667977647.0 計算出393073846353字節(jié) =多少GB 680667977647.0字節(jié)==多少GB 像下面這樣展示出,其他的數(shù)據(jù)都不要
已用流量: XXXX GB
剩余流量: XXXX GB
問題解答
回答1:接口數(shù)據(jù)返回給前端, 用js map方法處理就好了
相關(guān)文章:
1. android - Genymotion 微信閃退 not find plugin.location_google.GoogleProxyUI2. mac里的docker如何命令行開啟呢?3. android webview返回自動刷新4. objective-c - iOS開發(fā)使用什么對html進行代碼高亮5. angular.js - 關(guān)于ng-model和ng-bind的疑問6. html - 特殊樣式按鈕 點擊按下去要有凹下和彈起的效果7. angular.js - 在ionic下,利用javascript導(dǎo)入百度地圖,pc端可以顯示,移動端無法顯示8. javascript - 單個控件多個字段搜索9. javascript - npm安裝報錯 系統(tǒng)w7 求大神解答10. html5 - 微信瀏覽器視頻播放失敗
