123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- /**
- * Created by PhpStorm.
- * User: ASUS
- * Date: 2018/7/18
- * Time: 10:50
- */
- namespace Jobs\Model\Test;
- class K3Login
- {
- public function loginIfNeed()
- {
- $cookie_jar = './k3.ini';
- $K3Curl = new K3Curl();
- $data = array('597be128163613', '秦统业', 'Cwb20141222', '2052'); // 线上
- // $data = array('5b499257f851c8', 'liuxin', '123456', '2052'); // 线上
- $post_content = $this ->create_postdata($data);
- $loginurl = 'http://123.206.51.139/k3cloud/' . 'Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc';
- // $loginurl = 'http://192.168.0.135/k3cloud/' . 'Kingdee.BOS.WebApi.ServicesStub.AuthService.ValidateUser.common.kdsvc';
- $loginResult = $K3Curl -> MyCurlPost($loginurl, $post_content, $cookie_jar, TRUE);
- return $loginResult;
- }
- public function create_postdata($args){
- $postdata = array(
- 'format' => 1,
- 'useragent' => 'ApiClient',
- 'rid' => self::create_guid(),
- 'parameters' => $args,
- 'timestamp' => time(),
- 'v' => '1.0'
- );
- return json_encode($postdata);
- }
- public static function create_guid()
- {
- $charid = strtoupper(md5(uniqid(mt_rand(), true)));
- $hyphen = chr(45);// "-"
- $uuid = chr(123)// "{"
- . substr($charid, 0, 8) . $hyphen
- . substr($charid, 8, 4) . $hyphen
- . substr($charid, 12, 4) . $hyphen
- . substr($charid, 16, 4) . $hyphen
- . substr($charid, 20, 12)
- . chr(125);// "}"
- return $uuid;
- }
- }
|