Advertisement
burt_krizz

Untitled

Sep 22nd, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.53 KB | None | 0 0
  1. <?php
  2. $curl = curl_init();
  3. curl_setopt_array($curl, array(
  4. CURLOPT_URL => "https://apigw1.bot.or.th/bot/public/Stat-ExchangeRate/v2/DAILY_AVG_EXG_RATE/"
  5. . "?start_period=2019-09-22&"
  6. . "end_period=2019-09-23&",
  7. CURLOPT_RETURNTRANSFER => true,
  8. CURLOPT_ENCODING => "",
  9. CURLOPT_MAXREDIRS => 10,
  10. CURLOPT_TIMEOUT => 30,
  11. CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  12. CURLOPT_CUSTOMREQUEST => "GET",
  13. CURLOPT_HTTPHEADER => array(
  14. "x-ibm-client-id: 41a7650e-697b-4c11-968b-b982bac08687"
  15. ),
  16. ));
  17. $response = curl_exec($curl);
  18. $err = curl_error($curl);
  19. // echo print_r($err);
  20. $response = json_decode(curl_exec($curl),1);
  21. $data = $response["result"]["data"]["data_detail"];
  22. // print_r($data);
  23. ?>
  24.  
  25. <!doctype html>
  26. <html lang="en">
  27.   <head>
  28.     <!-- Required meta tags -->
  29.     <meta charset="utf-8">
  30.     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  31.     <!-- Bootstrap CSS -->
  32.     <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">
  33.     <title>Hello, world!</title>
  34.   </head>
  35.   <body>
  36.         <div class="container mt-5">
  37.             <center>
  38.                 <table class="table">
  39.                     <thead>
  40.                         <tr>
  41.                         <th scope="col">currency_id</th>
  42.                         <th scope="col">currency_name_th</th>
  43.                         <th scope="col">selling</th>
  44.                         </tr>
  45.                     </thead>
  46.                     <tbody>
  47.                     <?php
  48.                     foreach($data as $k=>$v){
  49.                         $currency_id = $v['currency_id'];
  50.                         $currency_name_th = $v['currency_name_th'];
  51.                         $selling = $v['selling'];
  52.                         echo'
  53.                             <tr>
  54.                                 <td>'.$currency_id.'</td>
  55.                                 <td>'.$currency_name_th.'</td>
  56.                                 <td>'.$selling.'</td>
  57.                             </tr>
  58.                        
  59.                         ';
  60.                     }
  61.                     ?>
  62.                     </tbody>
  63.                 </table>
  64.             </center>
  65.         </div>
  66.     <!-- Optional JavaScript -->
  67.     <!-- jQuery first, then Popper.js, then Bootstrap JS -->
  68.     <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  69.     <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
  70.     <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
  71.   </body>
  72. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement