Python语言API请求示例

http.client方法

获取邮件列表

import http.client
import mimetypes
from codecs import encode

conn = http.client.HTTPSConnection("domain-open-api.cuiqiu.com")
dataList = []
boundary = 'wL36Yn8afVp8Ag7AmP8qZ0SA4n1v9T'
dataList.append(encode('--' + boundary))
dataList.append(encode('Content-Disposition: form-data; name=mail_id;'))

dataList.append(encode('Content-Type: {}'.format('text/plain')))
dataList.append(encode(''))

dataList.append(encode("nM5GLra9Wo"))
dataList.append(encode('--' + boundary))
dataList.append(encode('Content-Disposition: form-data; name=token;'))

dataList.append(encode('Content-Type: {}'.format('text/plain')))
dataList.append(encode(''))

dataList.append(encode("4dfd31985d7e417cb8062b402950efb0"))
dataList.append(encode('--' + boundary))
dataList.append(encode('Content-Disposition: form-data; name=start_time;'))

dataList.append(encode('Content-Type: {}'.format('text/plain')))
dataList.append(encode(''))

dataList.append(encode("2021-07-15"))
dataList.append(encode('--' + boundary))
dataList.append(encode('Content-Disposition: form-data; name=end_time;'))

dataList.append(encode('Content-Type: {}'.format('text/plain')))
dataList.append(encode(''))

dataList.append(encode("2021-07-16"))
dataList.append(encode('--' + boundary))
dataList.append(encode('Content-Disposition: form-data; name=page;'))

dataList.append(encode('Content-Type: {}'.format('text/plain')))
dataList.append(encode(''))

dataList.append(encode("1"))
dataList.append(encode('--' + boundary))
dataList.append(encode('Content-Disposition: form-data; name=limit;'))

dataList.append(encode('Content-Type: {}'.format('text/plain')))
dataList.append(encode(''))

dataList.append(encode("10"))
dataList.append(encode('--'+boundary+'--'))
dataList.append(encode(''))
body = b'\r\n'.join(dataList)
payload = body
headers = {
   'Content-type': 'multipart/form-data; boundary={}'.format(boundary) 
}
conn.request("POST", "/v1/box/list", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

获取邮件详细

import http.client
import mimetypes
from codecs import encode

conn = http.client.HTTPSConnection("domain-open-api.cuiqiu.com")
dataList = []
boundary = 'wL36Yn8afVp8Ag7AmP8qZ0SA4n1v9T'
dataList.append(encode('--' + boundary))
dataList.append(encode('Content-Disposition: form-data; name=mail_id;'))

dataList.append(encode('Content-Type: {}'.format('text/plain')))
dataList.append(encode(''))

dataList.append(encode("08EJ98s9dWz"))
dataList.append(encode('--' + boundary))
dataList.append(encode('Content-Disposition: form-data; name=token;'))

dataList.append(encode('Content-Type: {}'.format('text/plain')))
dataList.append(encode(''))

dataList.append(encode("f76a1b32bacc4279bd6b731e59d8hj8837"))
dataList.append(encode('--' + boundary))
dataList.append(encode('Content-Disposition: form-data; name=box_id;'))

dataList.append(encode('Content-Type: {}'.format('text/plain')))
dataList.append(encode(''))

dataList.append(encode("23094"))
dataList.append(encode('--'+boundary+'--'))
dataList.append(encode(''))
body = b'\r\n'.join(dataList)
payload = body
headers = {
   'Content-type': 'multipart/form-data; boundary={}'.format(boundary) 
}
conn.request("POST", "/v1/box/detail", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))

requests框架

获取邮件列表

import requests

url = "https://domain-open-api.cuiqiu.com/v1/box/list"

payload={'mail_id': 'nM5GLra9Wo',
'token': '4dfd31985d7e417cb8062b402950efb0',
'start_time': '2021-07-15',
'end_time': '2021-07-16',
'page': '1',
'limit': '10'}
files=[

]
headers = {}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

获取邮件详细

import requests

url = "https://domain-open-api.cuiqiu.com/v1/box/detail"

payload={'mail_id': '08EJ98s9dWz',
'token': 'f76a1b32bacc4279bd6b731e59d8hj8837',
'box_id': '23094'}
files=[

]
headers = {}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

PHP语言API请求示例

获取邮件列表 $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, […]