VM暫存
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.6KB

  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. require_once('/home/bigbang/libs/phplibs/phpMQTT.php');
  4. class Parking_inseat_api_40701 extends CI_Controller {
  5. public function __construct() {
  6. parent::__construct();
  7. $this->load->model('reports/Update_pks_groups_model','update_pks_groups');
  8. }
  9. public function index()
  10. {
  11. $sel_pks_groups_all=$this->update_pks_groups->sel_pks_groups_all();
  12. foreach($sel_pks_groups_all as $key0 => $value0){
  13. $group_id="P1";
  14. $floors=isset($value0['floors']) ? $value0['floors'] : '' ;
  15. $station_no=isset($value0['station_no']) ? $value0['station_no'] : '' ;
  16. $tot=isset($value0['tot']) ? $value0['tot'] : '' ;
  17. $parked=isset($value0['parked']) ? $value0['parked'] : '' ;
  18. $spare=isset($value0['availables']) ? $value0['availables'] : '' ;
  19. $type=isset($value0['type']) ? $value0['type'] : '' ;
  20. $datetime=date('Y-m-d H:i:s'); ;
  21. $data=array(
  22. "floors" => $floors,
  23. "station_no" => $station_no,
  24. "tot" => $tot,
  25. "parked" => $parked,
  26. "spare" => $spare,
  27. "type" => $type,
  28. "datetime" => $datetime
  29. );
  30. $apijson= "http://altapi.altob.com.tw/api/Parking_inseat_api";
  31. $ch = curl_init();
  32. curl_setopt($ch, CURLOPT_HEADER, 0);
  33. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  34. curl_setopt($ch, CURLOPT_URL, $apijson);
  35. curl_setopt($ch, CURLOPT_POST, true);
  36. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
  37. $output = curl_exec($ch);
  38. curl_close($ch);
  39. }
  40. }
  41. }