import requests
url = "https://api.example.com/api" headers = { "Accept": "application/json", ... } params = { "param1": "value1", "param2": "value2", ... }
response = requests.get(url, headers=headers, params=params)
print(response.json())
// 定义API url和参数 $url = 'https://api.example.com/api'; $params = array( 'param1' => 'value1', 'param2' => 'value2', ... );
// 初始化curl $curl = curl_init();
// 设置curl选项 curl_setopt($curl, CURLOPT_URL, $url."?".http_build_query($params)); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, false);
// 发送请求 $response = curl_exec($curl);
// 关闭curl curl_close($curl);
// 打印返回结果 echo $response;
// 定义API url和参数 const url = "https://api.example.com/api"; const params = { param1: "value1", param2: "value2", ... };
// 发送get请求 fetch(url + "?" + new URLSearchParams(params)) .then(response => response.json()) .then(data => console.log(data));