require_once("curl.func.php");
$method = "POST";
$url = "http://open.liupai.net/driverexam/query";
$headers = NULL;
$params = array(
"appkey" => "yourappsecret",
"type" => "C1",
"subject" => "1",
"pagesize" => "1",
"pagenum" => "参数4",
"sort" => "normal",
"chapter" => "参数6"
);
$result = api_curl($method, $url, $headers, $params);
if ($result) {
$body = json_decode($result["body"], TRUE);
$status_code = $body["status"];
if ($status_code == "200") {
var_dump($body["result"]);
}else
var_dump($body);
}else
echo "发送请求失败";
/**
* 主函数
* @param args
*/
public static void main(String args[])
{
//请求地址设置
String url = "http://open.liupai.net/driverexam/query";
//请求方法设置
String requestMethod = "POST";
//请求头部设置
Map<String, String> headers = new HashMap<String, String>();
//请求参数设置
Map<String, String> params = new HashMap<String, String>();
params.put("appkey", "yourappsecret");
params.put("type", "C1");
params.put("subject", "1");
params.put("pagesize", "1");
params.put("pagenum", "参数4");
params.put("sort", "normal");
params.put("chapter", "参数6");
String result = proxyToDesURL(requestMethod, url, headers, params);
if (result != null) {
JSONObject jsonObject = JSONObject.parseObject(result);
String status_code = jsonObject.getString("status");
if (status_code.equals("200")) {
System.out.println("请求成功:" + jsonObject.getString("result"));
} else {
System.out.println(&q
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# 测试环境: python2.7
# 安装requests依赖 => pip install requests/ easy_install requests
import requests
import json
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
def api_send_request(method, url, params=None, headers=None):
'''
转发请求到目的主机
@param method str 请求方法
@param url str 请求地址
@param params dict 请求参数
@param headers dict 请求头
'''
method = str.upper(method)
if method == "POST":
return requests.post(url=url, data=params, headers=headers)
elif method == "GET":
return requests.get(url=url, params=params, headers=headers)
else:
return None
method = "POST"
url = "http://open.liupai.net/driverexam/query"
headers = None
params = {
"appkey" : "yourappsecret",
"type" : "C1",
"subject" : "1",
"pagesize" : "1",
"pagenum" : "参数4",
"sort" : "normal",
"chapter" : "参数6"
}
result = api_send_request(method=method, url=url, params=params, headers=headers)
if res
{
"status": 200,
"msg": "OK",
"result": {
"total": 1460,
"pagenum": 35,
"pagesize": 5,
"subject": 1,
"type": "C1,C2,C3",
"chapter": 0,
"sort": "normal",
"list": [
{
"question": "在这种路口怎样进行掉头?",
"option1": "A、在人行横道上掉头",
"option2": "B、进入路口后掉头",
"option3": "C、从右侧车道掉头",
"option4": "D、从中心线虚线处掉头",
"answer": "D",
"explain": "虚线处可掉头,实线是不能压的,所以实线处不能掉头、变道等。因此应该从图中中心线虚线处掉头才对。",
"pic": "https://open.liupai.net/data/driverexam/059be.jpg",
"type": "C1,C2,C3",
"chapter": "道路交通安全法律、法规和规章"
},
{
"question": "遇到这种情况的路口,以下做法正确的是什么?",
"option1": "A、沿左侧车道掉头",
"option2": "B、该路口不能掉头",
"option3": "C、选择中间车道掉头",
"option4": "D、在路口内掉头",
"answer": "B",
"explain": "此处有禁止掉头的标志,所以是不可以掉头的。",
"pic": "https://open.liupai.net/data/driverexam/65ddf.jpg",