Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => "https://apigw1.bot.or.th/bot/public/Stat-ExchangeRate/v2/DAILY_AVG_EXG_RATE/"
- . "?start_period=2019-09-22&"
- . "end_period=2019-09-23&",
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "GET",
- CURLOPT_HTTPHEADER => array(
- "x-ibm-client-id: 41a7650e-697b-4c11-968b-b982bac08687"
- ),
- ));
- $response = curl_exec($curl);
- $err = curl_error($curl);
- // echo print_r($err);
- $response = json_decode(curl_exec($curl),1);
- $data = $response["result"]["data"]["data_detail"];
- // print_r($data);
- ?>
- <!doctype html>
- <html lang="en">
- <head>
- <!-- Required meta tags -->
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
- <!-- Bootstrap CSS -->
- <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
- <title>Hello, world!</title>
- </head>
- <body>
- <div class="container mt-5">
- <center>
- <table class="table">
- <thead>
- <tr>
- <th scope="col">currency_id</th>
- <th scope="col">currency_name_th</th>
- <th scope="col">selling</th>
- </tr>
- </thead>
- <tbody>
- <?php
- foreach($data as $k=>$v){
- $currency_id = $v['currency_id'];
- $currency_name_th = $v['currency_name_th'];
- $selling = $v['selling'];
- echo'
- <tr>
- <td>'.$currency_id.'</td>
- <td>'.$currency_name_th.'</td>
- <td>'.$selling.'</td>
- </tr>
- ';
- }
- ?>
- </tbody>
- </table>
- </center>
- </div>
- <!-- Optional JavaScript -->
- <!-- jQuery first, then Popper.js, then Bootstrap JS -->
- <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
- <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
- <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement