-
驾考题库
[C#]- https://www.6api.net/api/driverexam/
- 阅读数:92768 上传时间:2020-11-21
- 示例代码
本代码示例是基于C#的六派数据接口进行数据请求 API服务请求的代码示例,使用前你需要:
①:通过https://www.6api.net/api/driverexam/ 申请API服务
以下是完整代码示例:
class Response
{
public string statusCode;
}
static void Main(string[] args)
{
string method = "POST";
string url = "http://open.liupai.net/driverexam/query";
Dictionary<string, string> param = new Dictionary<string, string>();
param.Add("appkey", "yourappsecret");
param.Add("type", "C1");//题目类型 分为A1,A3,B1,A2,B2,C1,C2,C3,D,E,F 默认C1
param.Add("subject", "1");//科目类别 1为科目一 4为科目四 默认1
param.Add("pagesize", "1");//每页数量 默认1
param.Add("pagenum", "参数4");//当前页数
param.Add("sort", "normal");//排序方式 正常排序normal 随机排序rand 默认normal
param.Add("chapter", "参数6");//章节 科目一为1-4 科目四为1-7
Dictionary<string, string> headers = null;
string result = api_send_request(method, url, param, headers);
if (result == "")
{
//返回内容异常,发送请求失败
Console.WriteLine("发送请求失败");
return;
}
Response res = new JavaScriptSerializer().Deserialize<Response>(result);
if (res.statusCode == "200") //有个别接口计费状态码为其他;请注意甄别
{
//状态码为200, 说明请求成功
Console.WriteLine(string.Format("请求成功: {0}", result));
}
else
{
//状态码非200, 说明请求失败
Console.WriteLine(string.Format("请求失败: {0}", result));
}
Console.ReadLine();
}