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.

51 lines
1.4KB

  1. <?php
  2. /*
  3. file: call_something_daily.php 每日呼叫匯整
  4. */
  5. require_once '/home/bigbang/apps/coworker/station.config.php';
  6. define('APP_NAME', 'call_something_daily'); // application name
  7. // 發生錯誤時集中在此處理
  8. function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
  9. {
  10. //$str = date('H:i:s')."|{$errstr}|{$errfile}|{$errline}|{$errno}\n";
  11. $str = date('H:i:s')."|{$errstr}\n";
  12. echo $str;
  13. error_log($str, 3, LOG_PATH.APP_NAME . '.' . date('Ymd').'.log.txt'); // 3代表參考後面的檔名
  14. }
  15. set_error_handler('error_handler', E_ALL);
  16. trigger_error('..start..');
  17. // 呼叫
  18. function post_data($url, $data)
  19. {
  20. try
  21. {
  22. $ch = curl_init();
  23. curl_setopt($ch, CURLOPT_URL, $url);
  24. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
  25. curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
  26. curl_setopt($ch, CURLOPT_POST, TRUE);
  27. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,10);
  28. curl_setopt($ch, CURLOPT_TIMEOUT, 10); //timeout in seconds
  29. $output = curl_exec($ch);
  30. curl_close($ch);
  31. trigger_error(__FUNCTION__ . "|{$url}|{$output}|" . json_encode($data));
  32. }
  33. catch(Exception $e)
  34. {
  35. trigger_error('ERROR: ' . $e->getMessage());
  36. }
  37. sleep(1); // sleep for 3 seconds
  38. }
  39. // 需要排程呼叫的加在這
  40. post_data('http://localhost/carpark.html/station_setting_query/', array('reload' => 1)); // 重新取得場站資訊
  41. trigger_error('..completed..');