K3login.Class.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: ASUS
  5. * Date: 2018/7/18
  6. * Time: 10:50
  7. */
  8. namespace Jobs\Model\Test;
  9. class K3Login
  10. {
  11. public function loginIfNeed()
  12. {
  13. $cookie_jar = './k3.ini';
  14. $K3Curl = new K3Curl();
  15. $data = array('597be128163613', '秦统业', 'Cwb20141222', '2052'); // 线上
  16. // $data = array('5b499257f851c8', 'liuxin', '123456', '2052'); // 线上
  17. $post_content = $this ->create_postdata($data);
  18. $loginurl = 'http://123.206.51.139/k3cloud/' . 'Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc';
  19. // $loginurl = 'http://192.168.0.135/k3cloud/' . 'Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc';
  20. $loginResult = $K3Curl -> MyCurlPost($loginurl, $post_content, $cookie_jar, TRUE);
  21. return $loginResult;
  22. }
  23. public function create_postdata($args){
  24. $postdata = array(
  25. 'format' => 1,
  26. 'useragent' => 'ApiClient',
  27. 'rid' => self::create_guid(),
  28. 'parameters' => $args,
  29. 'timestamp' => time(),
  30. 'v' => '1.0'
  31. );
  32. return json_encode($postdata);
  33. }
  34. public static function create_guid()
  35. {
  36. $charid = strtoupper(md5(uniqid(mt_rand(), true)));
  37. $hyphen = chr(45);// "-"
  38. $uuid = chr(123)// "{"
  39. . substr($charid, 0, 8) . $hyphen
  40. . substr($charid, 8, 4) . $hyphen
  41. . substr($charid, 12, 4) . $hyphen
  42. . substr($charid, 16, 4) . $hyphen
  43. . substr($charid, 20, 12)
  44. . chr(125);// "}"
  45. return $uuid;
  46. }
  47. }