$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; } }