curl -k -i "https://apis.juhe.cn/fapigw/train/query?key=key&search_type=xxx&departure_station=xxx&arrival_station=xxx&date=xxx&filter=&enable_booking=&departure_time_range="
       
            
      我的数据,接口名称上方查看
// 接口请求入参配置
$requestParams = [
    'key' => $apiKey,
    'search_type'=> 'xxx',
    'departure_station'=> 'xxx',
    'arrival_station'=> 'xxx',
    'date'=> 'xxx',
    'filter'=> '',
    'enable_booking'=> '',
    'departure_time_range'=> '',
];
$requestParamsStr = http_build_query($requestParams);
// 发起接口网络请求
$curl = curl_init();
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($curl, CURLOPT_URL, $apiUrl . '?' . $requestParamsStr);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
if (1 == strpos("$" . $apiUrl, "https://")) {
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
}
$response = curl_exec($curl);
$httpInfo = curl_getinfo($curl);
curl_close($curl);
// 解析响应结果
$responseResult = json_decode($response, true);
if ($responseResult) {
    // 网络请求成功。可依据业务逻辑和接口文档说明自行处理。
    var_dump($responseResult);
} else {
    // 网络异常等因素,解析结果异常。可依据业务逻辑自行处理。
    // var_dump($httpInfo);
    var_dump("请求异常");
}
       
            
      import requests
# 1960-列车站到站时刻表 - 代码参考(根据实际业务情况修改)
# 基本参数配置
apiUrl = 'https://apis.juhe.cn/fapigw/train/query'  # 接口请求URL
apiKey = '您申请的调用APIkey'  # 在个人中心->我的数据,接口名称上方查看
# 接口请求入参配置
requestParams = {
    'key': apiKey,
    'search_type': 'xxx',
    'departure_station': 'xxx',
    'arrival_station': 'xxx',
    'date': 'xxx',
    'filter': '',
    'enable_booking': '',
    'departure_time_range': '',
}
# 发起接口网络请求
response = requests.get(apiUrl, params=requestParams)
# 解析响应结果
if response.status_code == 200:
    responseResult = response.json()
    # 网络请求成功。可依据业务逻辑和接口文档说明自行处理。
    print(responseResult)
else:
    # 网络异常等因素,解析结果异常。可依据业务逻辑自行处理。
    print('请求异常')
       
            
      package main
import (
    "encoding/json"
    "fmt"
    "net/http"
    "net/url"
)
func main() {
    // 基本参数配置
    apiUrl := "https://apis.juhe.cn/fapigw/train/query"
    apiKey := "您申请的调用APIkey"
    // 接口请求入参配置
    requestParams := url.Values{}
    requestParams.Set("key", apiKey)
    requestParams.Set("search_type", "xxx")
    requestParams.Set("departure_station", "xxx")
    requestParams.Set("arrival_station", "xxx")
    requestParams.Set("date", "xxx")
    requestParams.Set("filter", "")
    requestParams.Set("enable_booking", "")
    requestParams.Set("departure_time_range", "")
    // 发起接口网络请求
    resp, err := http.Get(apiUrl + "?" + requestParams.Encode())
    if err != nil {
        fmt.Println("网络请求异常:", err)
        return
    }
    defer resp.Body.Close()
    var responseResult map[string]interface{}
    err = json.NewDecoder(resp.Body).Decode(&responseResult)
    if err != nil {
        fmt.Println("解析响应结果异常:", err)
        return
    }
    fmt.Println(responseResult)
}
       
            
      using System;
using System.Net;
using Newtonsoft.Json;
using System.Collections.Generic;
using System.Linq;
namespace Common_API_Test.Test_Demo
{
    class Csharp_get
    {
        static void Main(string[] args)
        {
            string url = "https://apis.juhe.cn/fapigw/train/query";
            string apiKey = "您申请的调用APIkey";
            Dictionary data = new Dictionary();
            data.Add("key", apiKey);
            data.Add( "search_type", "xxx");
            data.Add( "departure_station", "xxx");
            data.Add( "arrival_station", "xxx");
            data.Add( "date", "xxx");
            data.Add( "filter", "");
            data.Add( "enable_booking", "");
            data.Add( "departure_time_range", "");
            using (WebClient client = new WebClient())
            {
                string fullUrl = url + "?" + string.Join("&", data.Select(x => x.Key + "=" + x.Value));
                try
                {
                    string responseContent = client.DownloadString(fullUrl);
                    dynamic responseData = JsonConvert.DeserializeObject(responseContent);
                    if (responseData != null)
                    {
                        Console.WriteLine("Return Code: " + responseData["error_code"]);
                        Console.WriteLine("Return Message: " + responseData["reason"]);
                    }
                    else
                    {
                        Console.WriteLine("json解析异常!");
                    }
                }
                catch (Exception)
                {
                    Console.WriteLine("请检查其它错误");
                }
            }
        }
    }
}
       
            
      const axios = require('axios'); // npm install axios
// 基本参数配置
const apiUrl = 'https://apis.juhe.cn/fapigw/train/query';  // 接口请求URL
const apiKey = '您申请的调用APIkey';  // 在个人中心->我的数据,接口名称上方查看
// 接口请求入参配置
const requestParams = {
    key: apiKey,
    search_type: 'xxx',
    departure_station: 'xxx',
    arrival_station: 'xxx',
    date: 'xxx',
    filter: '',
    enable_booking: '',
    departure_time_range: '',
};
// 发起接口网络请求
axios.get(apiUrl, {params: requestParams})
    .then(response => {
        // 解析响应结果
        if (response.status === 200) {
            const responseResult = response.data;
            // 网络请求成功。可依据业务逻辑和接口文档说明自行处理。
            console.log(responseResult);
        } else {
            // 网络异常等因素,解析结果异常。可依据业务逻辑自行处理。
            console.log('请求异常');
        }
    })
    .catch(error => {
        // 网络请求失败,可以根据实际情况进行处理
        console.log('网络请求失败:', error);
    });
       
            
      package cn.juhe.test;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.stream.Collectors;
public class JavaGet {
    public static void main(String[] args) throws Exception {
        String apiKey = "你申请的key";
        String apiUrl = "https://apis.juhe.cn/fapigw/train/query";
        HashMap map = new HashMap<>();
        map.put("key", apiKey);
        map.put("search_type", "xxx");
        map.put("departure_station", "xxx");
        map.put("arrival_station", "xxx");
        map.put("date", "xxx");
        map.put("filter", "");
        map.put("enable_booking", "");
        map.put("departure_time_range", "");
        URL url = new URL(String.format("%s?%s", apiUrl, params(map)));
        BufferedReader in = new BufferedReader(new InputStreamReader((url.openConnection()).getInputStream()));
        String inputLine;
        StringBuffer response = new StringBuffer();
        while ((inputLine = in.readLine()) != null) {
            response.append(inputLine);
        }
        in.close();
        System.out.println(response);
    }
    public static String params(Map map) {
        return map.entrySet().stream()
                .map(entry -> {
                    try {
                        return entry.getKey() + "=" + URLEncoder.encode(entry.getValue(), StandardCharsets.UTF_8.toString());
                    } catch (Exception e) {
                        e.printStackTrace();
                        return entry.getKey() + "=" + entry.getValue();
                    }
                })
                .collect(Collectors.joining("&"));
    }
}
       
            
      // 基本参数配置
NSString *apiUrl = @"https://apis.juhe.cn/fapigw/train/query";  // 接口请求URL
NSString *apiKey = @"您申请的调用APIkey";  // 在个人中心->我的数据,接口名称上方查看
// 接口请求入参配置
NSDictionary *requestParams = @{
    @"key": apiKey,
    @"search_type": @"xxx",
    @"departure_station": @"xxx",
    @"arrival_station": @"xxx",
    @"date": @"xxx",
    @"filter": @"",
    @"enable_booking": @"",
    @"departure_time_range": @"",
};
// 发起接口网络请求
NSURLComponents *components = [NSURLComponents componentsWithString:apiUrl];
NSMutableArray *queryItems = [NSMutableArray array];
[requestParams enumerateKeysAndObjectsUsingBlock:^(NSString *key, NSString *value, BOOL *stop) {
    [queryItems addObject:[NSURLQueryItem queryItemWithName:key value:value]];
}];
components.queryItems = queryItems;
NSURL *url = components.URL;
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
    if (error) {
        // 网络请求异常处理
        NSLog(@"请求异常");
    } else {
        NSError *jsonError;
        NSDictionary *responseResult = [NSJSONSerialization JSONObjectWithData:data options:0 error:&jsonError];
        if (!jsonError) {
            // 网络请求成功处理
            // NSLog(@"%@", [responseResult objectForKey:@"error_code"]);
            NSLog(@"%@", responseResult);
        } else {
            // 解析结果异常处理
            NSLog(@"解析结果异常");
        }
    }
}];
[task resume];