foo.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. //$key = '6a7bdbaa-6bc1-4159-a2f4-07a13c8907d1';
  3. //$url = '62.141.88.61:8085/Thingworx/Things/connSmoppLibrary/Services/get_employee_status';
  4. /*
  5. "http://corp.prmsys.net/api/service/checkrfid"
  6. "dateTime":
  7. "number":
  8. "series":
  9. "rfid":
  10. "subnumber":
  11. "sectionId":
  12. "http://corp.prmsys.net/api/service/addwork"
  13. "dateTime":
  14. "number":
  15. "series":
  16. "diagnosticCard":
  17. "subnumber":
  18. "kind":
  19. "sectionId":
  20. */
  21. $url = $_SERVER['SERVER_NAME'].'/api/service/addwork';
  22. //$url = $_SERVER['SERVER_NAME'].'/api/service/checkrfid';
  23. $key = '07a13c8907d1-6a7bdba1-a2fz-aatgu4j';
  24. //checkrfid
  25. $jsonEncoded = json_encode(
  26. [
  27. "series" => "2ЭС5К",
  28. "number"=>"0146А",
  29. "subnumber"=>"11374428",
  30. "diagnosticCard"=>"e95386f0-9bad-11e9-80d5-005056011052",
  31. "rfid"=>"2545856584",
  32. "kind"=>"ТР-1",
  33. "dateTime" => "1562077752",
  34. "sectionId"=>"ac895a1e-f049-11e1-8e8b-001517e6ca10",
  35. ]);
  36. //код 4452578
  37. //$jsonEncoded = json_encode(
  38. // [
  39. // "locomotive_serie" => "2ЭС5К",
  40. // "number"=>"0275А",
  41. // "subnumber"=>"12025490",
  42. // "diagnosticMap"=>"004d9e52-9848-11e9-80d5-005056011052",
  43. // "typeOfRepair"=>"ТР-1",
  44. // "dateTime" => "1562077752",
  45. // "sectionId"=>"34d11b7c-f04a-11e1-8e8b-001517e6ca10",
  46. // "PP-5dbc36ea-47e9-472f-ba17-b45422fc25ac"=>array()
  47. // ]);
  48. $curl = curl_init();
  49. curl_setopt($curl, CURLOPT_URL, $url);
  50. curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json","Accept: application/json","appKey: " . $key));
  51. curl_setopt($curl, CURLOPT_TIMEOUT, 60);
  52. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  53. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  54. curl_setopt($curl, CURLOPT_POST, 1);
  55. curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonEncoded);
  56. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  57. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  58. $result = curl_exec($curl);
  59. //$info = curl_getinfo($curl, CURLINFO_HEADER_OUT);
  60. //$result = json_decode($result,true);
  61. echo "<pre>";var_dump($jsonEncoded); echo "</pre>";
  62. curl_close($curl);
  63. function milliseconds()
  64. {
  65. $mt = explode(' ', microtime());
  66. return ((int)$mt[1]) * 1000 + ((int)round($mt[0] * 1000));
  67. }
  68. echo "<pre>";var_dump($result); echo "</pre>";
  69. ?>