api_addremark.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. defined('YII_DEBUG') or define('YII_DEBUG', true);
  3. defined('YII_ENV') or define('YII_ENV', 'dev');
  4. require 'api/vendor/autoload.php';
  5. require 'api/vendor/yiisoft/yii2/Yii.php';
  6. $config = require 'api/config/web.php';
  7. (new yii\web\Application($config));
  8. $res = new app\models\LocomotiveModel();
  9. $locomotiveModel = new app\models\LocomotiveModel();
  10. $locomotiveModel->project_id = '4627';
  11. $time = $locomotiveModel->milliseconds();
  12. $time = explode(' ', microtime())[1];
  13. //$time = microtime();
  14. //echo $time."<br>";
  15. //$params['number'] = '029А';
  16. //$params['subnumber'] = '11360534';
  17. //$params['diagnosticMap'] = 'e3fc0d5d-1ee2-11ea-80d6-005056011052';
  18. $params['number'] = '029А';
  19. $params['subnumber'] = '11360534';
  20. $params['diagnosticMap'] = '26f77970-1fee-11ea-80d6-005056011052';
  21. $params['date'] = $time;//'1562877877';$locomotiveModel->milliseconds();
  22. $params['worker'] = 'f4a9cbc2-e472-11e2-aaad-ac162db0b20c';//f4a9cbc2-e472-11e2-aaad-ac162db0b20c - гориченко '7b8ebba7-c9a4-11e7-80cd-0050560110fa';//'bbd19a7f-bf7d-11e7-80cd-0050560110fa';
  23. $params['source'] = 'c92e78e9-e104-11e7-80cc-005056011052';
  24. $params['description'] = 'TWX and SMoPP integration testing';
  25. $params['isSCWorksNeeded'] = '';
  26. $params['plant'] = '';
  27. $params['sectionId'] = '56edc8c8-f04a-11e1-8e8b-001517e6ca10';
  28. //$result = $locomotiveModel->addRemark($params);
  29. //$params = array();
  30. //$params['section_id'] = 'ac8959ef-f049-11e1-8e8b-001517e6ca10';
  31. //$params['sectionId'] = 'ac8959f0-f049-11e1-8e8b-001517e6ca10';
  32. //echo '123';
  33. //var_dump( $result);
  34. TWXrequest($params);
  35. function TWXrequest($params)
  36. {
  37. //app key 6a7bdbaa-6bc1-4159-a2f4-07a13c8907d1
  38. // $url = "http://62.141.88.61:8085/Thingworx/Things/connSmoppLibrary/Services/get_section_remarks";
  39. //$url = "http://62.141.88.61:8085/Thingworx/Things/connSmoppLibrary/Services/add_remark";
  40. $url = "http://qaplatform.digitaldepot.ru:8085/Thingworx/Things/connSmoppLibrary/Services/add_remark";
  41. // $url = "http://62.141.88.61:8085/Thingworx/Things/connSmoppLibrary/Services/get_sources_of_comments";
  42. $jsonEncoded = json_encode($params);
  43. $curl = curl_init();
  44. curl_setopt($curl, CURLOPT_URL, $url);
  45. curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "AppKey: 33cd23bb-3b03-4638-afef-7104a13e9211", "Accept:application/json"));
  46. // curl_setopt($curl, CURLOPT_USERPWD, sprintf('%s:%s', "Smopp", "2050.Digital"));
  47. curl_setopt($curl, CURLOPT_TIMEOUT, 60);
  48. curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
  49. curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
  50. curl_setopt($curl, CURLOPT_POST, 1);
  51. curl_setopt($curl, CURLOPT_POSTFIELDS, $jsonEncoded);
  52. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  53. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  54. // var_dump($jsonEncoded);
  55. $result = curl_exec($curl);
  56. $uuid = json_decode($result)->RemarkId;
  57. echo "uuid ".$uuid;
  58. curl_close($curl);
  59. var_dump($result);
  60. // var_dump($result);
  61. }
  62. ?>
  63. ?>