|
|
|
รบกวนสอบถามเรื่อง การเรียกใช้งาน API กับ php และ javascript |
|
|
|
|
|
|
|
ผมนำข้อมูลมาจาก Link API
$url = "{url}/api/last_visit";
$data=file_get_contents($url);
จึงได้ข้อมูล 1 ชุด
{"hours":24,"uservisit":[{"datetime":"2023-11-06 11:00:00","count":1},{"datetime":"2023-11-06 10:00:00","count":7},{"datetime":"2023-11-06 09:00:00","count":7},{"datetime":"2023-11-06 08:00:00","count":3},{"datetime":"2023-11-06 07:00:00","count":1},{"datetime":"2023-11-06 06:00:00","count":0},{"datetime":"2023-11-06 05:00:00","count":0},{"datetime":"2023-11-06 04:00:00","count":0},{"datetime":"2023-11-06 03:00:00","count":0},{"datetime":"2023-11-06 02:00:00","count":1},{"datetime":"2023-11-06 01:00:00","count":0},{"datetime":"2023-11-06 00:00:00","count":0},{"datetime":"2023-11-05 23:00:00","count":0},{"datetime":"2023-11-05 22:00:00","count":0},{"datetime":"2023-11-05 21:00:00","count":0},{"datetime":"2023-11-05 20:00:00","count":2},{"datetime":"2023-11-05 19:00:00","count":0},{"datetime":"2023-11-05 18:00:00","count":1},{"datetime":"2023-11-05 17:00:00","count":1},{"datetime":"2023-11-05 16:00:00","count":5},{"datetime":"2023-11-05 15:00:00","count":3},{"datetime":"2023-11-05 14:00:00","count":3},{"datetime":"2023-11-05 13:00:00","count":2},{"datetime":"2023-11-05 12:00:00","count":2}]}
ผมจะต้องเขียนยังไง เพื่อให้ได้ข่อมูล
hours=24
datetime=array("2023-11-06 11:00:00","2023-11-06 10:00:00",.........);
count=array(1,7,...........);
หรือถ้าเป็น javascript
$JSON_ENC= json_encode($data);
<script>
data_datetime: ["2023-11-06 11:00:00", "2023-11-06 10:00:00", ............]
data_count: [1,7,...........]
</script>
ขอบคุณครับ
Tag : PHP, Web API
|
ประวัติการแก้ไข 2023-11-06 11:01:31
|
|
|
|
|
Date :
2023-11-06 11:00:37 |
By :
alapod2000 |
View :
362 |
Reply :
1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับ ถามเองตอบเอง ตาหน่าย
obj.patientvisit[0].datetime
obj.patientvisit[0].count
|
ประวัติการแก้ไข 2023-11-06 11:41:51
|
|
|
|
Date :
2023-11-06 11:35:05 |
By :
alapod2000 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 02
|