require_once("curl.func.php");
$method = "POST";
$url = "http://open.liupai.net/huangli/query";
$headers = NULL;
$params = array(
"appkey" => "yourappsecret",
"year" => "2020",
"month" => "11",
"day" => "11"
);
$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/huangli/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("year", "2020");
params.put("month", "11");
params.put("day", "11");
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/huangli/query"
headers = None
params = {
"appkey" : "yourappsecret",
"year" : "2020",
"month" : "11",
"day" : "11"
}
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 == &
{
"status": 200,
"msg": "OK",
"result": {
"year": "2020",
"month": "11",
"day": "11",
"yangli": "公元2020年11月11日",
"nongli": "农历二〇二〇年九月廿六",
"star": "天蝎座",
"taishen": "房床碓外正东",
"wuxing": "天上火",
"chong": "冲(壬子)鼠",
"sha": "煞北",
"shengxiao": "鼠",
"jiri": "青龙危日",
"zhiri": "靑龙(黄道日)",
"xiongshen": "九坎 招摇 厌对 九焦 复日 重日",
"jishenyiqu": "时阴 三合 六仪 玉堂",
"caishen": "正北",
"xishen": "东南",
"fushen": "正北",
"suici": [
"庚子年",
"丁亥月",
"戊午日"
],
"yi": [
"【日值岁破",
"大事勿用】",
"搬家",
"装修",
"结婚",
"入宅",
"领证",
"动土",
"订婚",
"安葬",
"修造",
"祭祀",
"纳财",
"捕捉",
"嫁娶",
"纳采",
"移徙",
"立券",
"竖柱",
"求财",
"招赘",
"纳婿",
"取渔"
],
"ji": [
"【日值岁破",
"大事勿用】",
"开业",
"开工",
"安床",
"出行",
"上梁",
"交易",
"开张",
"旅游",
"祈福",
"开市",
"纳畜",
"伐木",
"盖屋",
"冠笄",
"斋醮",
"行舟"
],
"eweek": "WEDNESDAY",
"emonth": "November",
"week": "三"
}
}