12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- namespace call;
- class Haoxiaoyun
- {
- protected $domain = 'https://www.ixiaoguanjia.cn';
- /**
- * 登陆接口
- */
- public function login($phone)
- {
- $url = '/api/login/login';
- $param = [
- 'account' => $phone,
- 'password' => $phone
- ];
- $headers = array(
- 'accept: application/json',
- 'Content-Type: multipart/form-data'
- );
- $rs = $this->curl($url, $param, $headers);
- return json_decode($rs, true);
- }
- public function bind($caller, $callee, $type = 1)
- {
- $login = $this->login($caller);
- if ($login['code'] != 1) return $login;
- $url = '/api/call/callBind';
- $param = [
- 'type' => $type,
- 'callee' => $callee
- ];
- $headers = array(
- 'accept: application/json',
- 'token: ' . $login['data']['user']['token'],
- 'apptype: android',
- 'appcode: 100',
- 'Content-Type: multipart/form-data'
- );
- $rs = $this->curl($url, $param, $headers);
- return json_decode($rs, true);
- }
- /**
- * curl请求
- *
- * @param String $url
- * @param Array $param
- * @return String
- */
- public function curl($url, $param, $header)
- {
- $curl = curl_init();
- curl_setopt_array($curl, array(
- CURLOPT_URL => $this->domain . $url,
- CURLOPT_RETURNTRANSFER => true,
- CURLOPT_ENCODING => "UTF-8",
- CURLOPT_MAXREDIRS => 10,
- CURLOPT_TIMEOUT => 30,
- CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
- CURLOPT_CUSTOMREQUEST => "POST",
- CURLOPT_POSTFIELDS => $param,
- CURLOPT_HTTPHEADER => $header,
- ));
- $response = curl_exec($curl);
- // $err = curl_error($curl);
- curl_close($curl);
- // if ($err) {
- // echo "cURL Error #:" . $err;
- // } else {
- // echo $response;
- // }
- return $response;
- }
- }
|