api_workmes.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. //$subnumber = $_REQUEST['subnumber'];
  3. //$time = date('Y-m-d\TH:i:s');
  4. //$params['user_id'] = "0231698c-e473-11e2-aaad-ac162db0b20c"; //nkandabaev
  5. $params['user_id'] = "023169da-e473-11e2-aaad-ac162db0b20c"; //kotob
  6. $params['work_id'] = "a5791775-d6cf-4a8e-9df6-44caaf93ec0c";
  7. //$params['user_id'] = "023169da-e473-11e2-aaad-ac162db0b20c";
  8. //$params['work_id'] = "1479795c-c1ab-4065-b31e-2e0e5d01721e";
  9. //$params['work_id'] = "2f298072-0ac3-495d-a75e-0a30803469b2";
  10. // $params['work_id'] = "735f7f76-5982-4b82-a60c-3b4a88d0d7eb";
  11. //$params['user_id'] = "0231698c-e473-11e2-aaad-ac162db0b20c";
  12. //$params['work_id'] = "9957c42a-234f-4f8e-99e7-1b4f6165a422";
  13. // $params['id_reason'] = "прочее";
  14. // $params['comment'] = "прочее";
  15. TWXrequest($params);
  16. function TWXrequest($params)
  17. {
  18. //$url = "http://devplatform.digitaldepot.ru:8085/Thingworx/Things/SMoPPIntegrationLibrary/Services/work_detail";
  19. $url = "http://devplatform.digitaldepot.ru:8085/Thingworx/Things/2050UserLibraryExp/Services/work_measurements";
  20. $jsonEncoded = json_encode($params);
  21. $curl = curl_init();
  22. curl_setopt($curl, CURLOPT_URL, $url);
  23. curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "AppKey: 6a7bdbaa-6bc1-4159-a2f4-07a13c8907d1", "Accept:application/json"));
  24. // curl_setopt($curl, CURLOPT_USERPWD, sprintf('%s:%s', "Smopp", "2050.Digital"));
  25. curl_setopt($curl, CURLOPT_TIMEOUT, 60);
  26. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  27. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  28. curl_setopt($curl, CURLOPT_POST, 1);
  29. curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonEncoded);
  30. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  31. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  32. // var_dump($jsonEncoded);
  33. $result = curl_exec($curl);
  34. $json = json_decode($result);
  35. $data= $json->data;
  36. //016 11360336 e6b6b19d-d9c3-11e9-80d5-005056011052
  37. //016 11360328 e6b6b19e-d9c3-11e9-80d5-005056011052
  38. // $uuid = json_decode($result)->RemarkId;
  39. // echo "uuid ".$uuid;
  40. // curl_close($curl);
  41. foreach ($data as $obj)
  42. {
  43. //var_dump($obj);
  44. foreach ($obj as $name=>$val)
  45. {
  46. //var_dump($name);
  47. //var_dump($val);
  48. //echo $val;
  49. echo "<b>$name:</b> ";
  50. //print_r($val);
  51. var_dump($val);
  52. echo "<br>";
  53. }
  54. echo "<p></p>";
  55. }
  56. var_dump($data);
  57. }
  58. ?>