1 终端命令
终端命令为,
curl -H "Content-Type: application/json" -X POST --data '{
"appkey":"xxx",
"action": "xxx",
"date":"xxx"
}' "http://xxx"
返回结果为,
xxx
2 python2脚本
python2代码为,
import requests
import json
def net_post(url, data, timeout=1000):
"""
A http post method.
"""
headers = {'Content-type': 'application/json', 'Accept': 'text/plain'}
data = json.dumps(data, ensure_ascii=False)
response = requests.post(url, data=data, headers=headers, timeout=timeout)
data = json.loads(response.content, encoding="utf-8")
return data
data_to_export = {
"appkey":"xxx",
"action": "xxx",
"date":"xxx"
}
url = "http://xxx"
data = net_post(url, data_to_export)
print(data)
返回结果为,
xxx