...
|
...
|
@@ -322,12 +322,13 @@ class App extends Api |
|
|
$param['key'] = $key;
|
|
|
$param['image_id'] = $image_id;
|
|
|
$param['sign'] = $this->getSign($param);
|
|
|
$result = $this->httpPost($url,$param);
|
|
|
list($http_code,$body) = $this->httpPost($url,$param);
|
|
|
|
|
|
file_put_contents('a.txt',print_r($result,true),FILE_APPEND);
|
|
|
file_put_contents('a.txt','\r\n',FILE_APPEND);
|
|
|
if($http_code != 200) {
|
|
|
$this->error('数管识别返回失败','',$http_code);
|
|
|
}
|
|
|
|
|
|
$data = json_decode($result,true);
|
|
|
$data = json_decode($body,true);
|
|
|
Db::startTrans();
|
|
|
//保存数管信息
|
|
|
$arr = [
|
...
|
...
|
@@ -368,25 +369,7 @@ class App extends Api |
|
|
}
|
|
|
}
|
|
|
Db::commit();
|
|
|
$this->success('SUCCESS',$result);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 模拟调用
|
|
|
*/
|
|
|
private function test(){
|
|
|
dump(getAddress("N39.085660E117.068135"));
|
|
|
exit();
|
|
|
$url = "http://gangjuren.net/api/app/getImageInfo";
|
|
|
$arr = [
|
|
|
'url' => "http://company.zzspjob.com/6b408e79f3a21ac02746b218f6cbc99@3x.png",
|
|
|
'app_id' => 'gjra2g11dg56ad7bb71',
|
|
|
'customer_id' => '1',
|
|
|
'access_token' => 'e508a6c25ed2ec1237fa8a0ba8a09357ff83b8c8',
|
|
|
'image_id' => '1',
|
|
|
];
|
|
|
$result = $this->httpPost($url,$arr);
|
|
|
$this->success('',$result);
|
|
|
$this->success('SUCCESS',$body);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -421,14 +404,24 @@ class App extends Api |
|
|
curl_setopt($curl, CURLOPT_POST, true); // 发送一个常规的Post请求
|
|
|
curl_setopt($curl, CURLOPT_POSTFIELDS, $data); // Post提交的数据包
|
|
|
//curl_setopt($curl, CURLOPT_TIMEOUT, 120); // 设置超时限制防止死循环
|
|
|
curl_setopt($curl, CURLOPT_HEADER, false); // 显示返回的Header区域内容
|
|
|
curl_setopt($curl, CURLOPT_HEADER, true); // 显示返回的Header区域内容
|
|
|
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // 获取的信息以文件流的形式返回
|
|
|
$result = curl_exec($curl); // 执行操作
|
|
|
if (curl_errno($curl)) {
|
|
|
echo 'Error POST'.curl_error($curl);
|
|
|
}
|
|
|
return curl_error($curl);
|
|
|
}
|
|
|
// 获得响应结果里的:头大小
|
|
|
$headerSize = curl_getinfo($curl, CURLINFO_HEADER_SIZE);
|
|
|
$http_code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
|
|
|
// 根据头大小去获取body信息内容
|
|
|
$header = substr($result,0,$headerSize);
|
|
|
file_put_contents('b.txt',print_r(['time' => date('Y-m-d H:i:s',time()), 'content' => $header],true),FILE_APPEND);
|
|
|
file_put_contents('b.txt','\r\n',FILE_APPEND);
|
|
|
$body = substr($result,$headerSize,strlen($result)-$headerSize);
|
|
|
file_put_contents('a.txt',print_r(['time' => date('Y-m-d H:i:s',time()), 'content' => $body],true),FILE_APPEND);
|
|
|
file_put_contents('a.txt','\r\n',FILE_APPEND);
|
|
|
curl_close($curl); // 关键CURL会话
|
|
|
return $result; // 返回数据
|
|
|
return array($http_code,$body); // 返回数据
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
|