调用示例
$url = 'https://api.bugpk.com/api/citywid';
$params = [
'key' => 'value' // 请替换实际参数
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url . '?' . http_build_query($params));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
import requests
url = "https://api.bugpk.com/api/citywid"
params = {
"key": "value" # 请替换实际参数
}
response = requests.get(url, params=params)
print(response.text)
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class ApiTest {
public static void main(String[] args) {
try {
String url = "https://api.bugpk.com/api/citywid?key=value";
URL obj = new URL(url);
HttpURLConnection con = (HttpURLConnection) obj.openConnection();
con.setRequestMethod("GET");
BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
String inputLine;
StringBuffer response = new StringBuffer();
while ((inputLine = in.readLine()) != null) {
response.append(inputLine);
}
in.close();
System.out.println(response.toString());
} catch (Exception e) {
e.printStackTrace();
}
}
}
const url = 'https://api.bugpk.com/api/citywid';
const params = new URLSearchParams({
key: 'value' // 请替换实际参数
});
fetch(`${url}?${params}`)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
返回结果示例
{
"success": true,
"type": "substring",
"count": 3,
"results": [
{
"name": "北京市朝阳",
"id": "101010300",
"type": "substring",
"position": 9
},
{
"name": "辽宁省朝阳市朝阳",
"id": "101071201",
"type": "substring",
"position": 9
},
{
"name": "吉林省长春市朝阳",
"id": "101060110",
"type": "substring",
"position": 18
}
]
}
返回参数说明
| 参数名 |
类型 |
说明 |
示例 |
| success |
string |
状态码 |
|
| type |
string |
类型 |
|
| count |
string |
结果条数 |
|
| results |
string |
信息 |
|