|
@@ -945,7 +945,9 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
{
|
|
|
$client_ip = isset($data['ip']) && $data['ip']??$_SERVER['REMOTE_ADDR'];
|
|
|
// 使用 IPinfo 服务获取 IP 信息
|
|
|
- $api_url = "https://ipinfo.io/{$client_ip}/json";
|
|
|
+// $api_url = "https://ipinfo.io/{$client_ip}/json";
|
|
|
+ //http://ip-api.com/json/117.136.12.79?lang=zh-cn
|
|
|
+ $api_url = "http://ip-api.com/json/{$client_ip}/?lang=zh-cn";
|
|
|
$ch = curl_init($api_url);
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
$response = curl_exec($ch);
|
|
@@ -953,11 +955,11 @@ class PublicRpcService implements PublicRpcServiceInterface
|
|
|
// 解析 JSON 响应
|
|
|
$ip_info = json_decode($response, true);
|
|
|
// 提取地址和经纬度
|
|
|
- if ($ip_info && !isset($ip_info['bogon'])) {
|
|
|
- $latitude = explode(',', $ip_info['loc'])[0];
|
|
|
- $longitude = explode(',', $ip_info['loc'])[1];
|
|
|
- $ip_info['latitude'] = $latitude;
|
|
|
- $ip_info['longitude'] = $longitude;
|
|
|
+ if ($ip_info) {
|
|
|
+// $latitude = explode(',', $ip_info['loc'])[0];
|
|
|
+// $longitude = explode(',', $ip_info['loc'])[1];
|
|
|
+ $ip_info['latitude'] = $ip_info['lat'];
|
|
|
+ $ip_info['longitude'] = $ip_info['lon'];
|
|
|
return Result::success($ip_info);
|
|
|
} else {
|
|
|
$data['ip'] = '101.254.114.212';
|