up
This commit is contained in:
@@ -11,6 +11,7 @@ namespace app\index\controller\admin;
|
||||
use app\common\model\Images as ImagesModel;
|
||||
use app\common\model\Users;
|
||||
use GuzzleHttp\Client;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use think\facade\Config;
|
||||
use think\Db;
|
||||
use think\Exception;
|
||||
@@ -115,16 +116,23 @@ class Images extends Base
|
||||
public function getIpInfo()
|
||||
{
|
||||
if ($this->request->isPost()) {
|
||||
$ip = $this->request->post('ip');
|
||||
$client = new Client();
|
||||
$response = $client->get('http://ip.taobao.com/service/getIpInfo.php?ip=' . $ip);
|
||||
if ($response->getStatusCode() == 200) {
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
if (isset($data['code']) && $data['code'] == 0) {
|
||||
return $this->success('获取成功', null, isset($data['data']) ? $data['data'] : null);
|
||||
try {
|
||||
$data = null;
|
||||
$ip = $this->request->post('ip');
|
||||
$client = new Client();
|
||||
$response = $client->get('http://ip.taobao.com/service/getIpInfo.php?ip=' . $ip);
|
||||
if ($response->getStatusCode() == 200) {
|
||||
$data = json_decode($response->getBody()->getContents(), true);
|
||||
if (isset($data['code']) && $data['code'] == 0) {
|
||||
$data = isset($data['data']) ? $data['data'] : null;
|
||||
}
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
return $this->error('获取失败');
|
||||
} catch (RequestException $e) {
|
||||
return $this->error('淘宝接口异常');
|
||||
}
|
||||
return $this->error('获取失败');
|
||||
return $this->success('获取成功', null, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user