require_once("curl.func.php");
$method = "POST";
$url = "http://open.liupai.net/bankaps/query";
$headers = NULL;
$params = array(
"appkey" => "yourappsecret",
"bankcard" => "6226220113414063",
"bank" => "中国民生银行",
"province" => "北京",
"city" => "北京市",
"key" => "南二环支行",
"page" => "1",
"lng" => "116.4051900000",
"lat" => "39.8655030000",
"ds" => "5"
);
$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/bankaps/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("bankcard", "6226220113414063");
params.put("bank", "中国民生银行");
params.put("province", "北京");
params.put("city", "北京市");
params.put("key", "南二环支行");
params.put("page", "1");
params.put("lng", "116.4051900000");
params.put("lat", "39.8655030000");
params.put("ds", "5");
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("请求失败:" + jsonObject.getString("msg"));
}
} else {
System.out.println("发送请求异常");
#!/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/bankaps/query"
headers = None
params = {
"appkey" : "yourappsecret",
"bankcard" : "6226220113414063",
"bank" : "中国民生银行",
"province" : "北京",
"city" : "北京市",
"key" : "南二环支行",
"page" : "1",
"lng" : "116.4051900000",
"lat" : "39.8655030000",
"ds" : "5"
}
result = api_send_request(method=method, url=url, params=params, headers=headers)
if result:
body = result.result
response = json.loads(body)
status_code = response["status"]
if (status_code == "200"):
print(&qu
{
"status": 200,
"msg": "OK",
"result": {
"page": 1,
"bank": "中国民生银行",
"city": "北京市",
"province": "北京",
"totalpage": 1,
"record": [
{
"address": "北京市东城区永定门外大街101号百荣世贸商城a座1层",
"bank": "中国民生银行",
"city": "北京市",
"province": "北京",
"bankCode": "305100001395",
"lName": "中国民生银行股份有限公司北京南二环支行",
"tel": "(010)87802421",
"info": {
"bank_id": "13",
"province_id": "1",
"city_id": "35",
"lat": "39.8655030000",
"lng": "116.4051900000"
}
}
],
"card": "6226220113414063",
"key": "南二环支行",
"totalcount": "1"
}
}