|
本帖最后由 非相 于 2016-1-2 00:19 编辑
发起请求:
- <?php
- function curl_post($url,$data='',$timeout=30,$header=array()){
- $arrCurlResult = array();
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);//ssl检测跳过
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HEADER, false);
- curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
- curl_setopt ( $ch,CURLOPT_REFERER,"");
- $output = curl_exec($ch);
- $responseCode = curl_getinfo($ch,CURLINFO_HTTP_CODE);
- $arrCurlResult['output'] = $output;//返回结果
- $arrCurlResult['code'] = $responseCode;//返回http状态
- curl_close($ch);
- unset($ch);
- return $arrCurlResult;
- }
- $header=array(
- 'Content-Type:application/json',
- 'X-Gizwits-Application-Id:d144ac6422ca444d8345xxxxxxxx'//appid隐藏了
- );
- $params=array(
- "phone_id"=> "apiary"
- );
- $params_query=json_encode($params);
- $result=@curl_post('http://api.gizwits.com/app/users',$params_query,$header,30);
- echo '<pre>';
- print_r($result);
- ?>
复制代码
返回内容:
Array( [output] => {"error_message":"appid invalid!","error_code":9003,"detail_message":null} [code] => 400)
|
|