12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- <?php namespace Im\Src;
- use Dever;
- class Test
- {
- private $host = 'http://39.100.131.66:18080/';
- private $key = 'hlhuala1999';
- private $uid = 1;
- # 注册
- public function reg()
- {
- $param['userId'] = $this->uid;
- $param['name'] = 'suwibin';
- $param['displayName'] = 'rabin';
- $result = $this->result('admin/user/create', $param);
-
- return $result;
- }
- # 获取token
- public function token()
- {
- $param['userId'] = $this->uid;
- $param['clientId'] = $this->uid;
- $param['platform'] = 5;
- $result = $this->result('admin/user/get_token', $param);
-
- return $result;
- }
- private function result($uri, $param)
- {
- $url = $this->host . $uri;
- $result = Dever::curl($url, $param, 'post', true, $this->sign());
- return $result;
- }
- private function sign()
- {
- $option['nonce'] = $this->nonce();
- $option['timestamp'] = $this->timestamp();
- $option['sign'] = sha1($option['nonce'] . '|' . $this->key . '|' . $option['timestamp']);
- return $option;
- }
- private function nonce()
- {
- return substr(sha1(microtime()), rand(10, 15));
- }
- private function timestamp()
- {
- list($msec, $sec) = explode(' ', microtime());
- $msectime = (float)sprintf('%.0f', (floatval($msec) + floatval($sec)) * 1000);
- return $msectime;
- }
- }
|