JavaScript语言API请求示例

ES6 Fetch方式请求(适合现代浏览器)

获取邮件列表

var formdata = new FormData();
formdata.append("mail_id", "nM5GLra9Wo");
formdata.append("token", "4dfd31985d7e417cb8062b402950efb0");
formdata.append("start_time", "2021-07-15");
formdata.append("end_time", "2021-07-16");
formdata.append("page", "1");
formdata.append("limit", "10");

var requestOptions = {
  method: 'POST',
  body: formdata,
  redirect: 'follow'
};

fetch("https://domain-open-api.cuiqiu.com/v1/box/list", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

获取邮件详细

var formdata = new FormData();
formdata.append("mail_id", "08EJ98s9dWz");
formdata.append("token", "f76a1b32bacc4279bd6b731e59d8hj8837");
formdata.append("box_id", "23094");

var requestOptions = {
  method: 'POST',
  body: formdata,
  redirect: 'follow'
};

fetch("https://domain-open-api.cuiqiu.com/v1/box/detail", requestOptions)
  .then(response => response.text())
  .then(result => console.log(result))
  .catch(error => console.log('error', error));

 


Axios方式请求(适合VUE、React等框架)

获取邮件列表

var axios = require('axios');
var FormData = require('form-data');
var data = new FormData();
data.append('mail_id', 'nM5GLra9Wo');
data.append('token', '4dfd31985d7e417cb8062b402950efb0');
data.append('start_time', '2021-07-15');
data.append('end_time', '2021-07-16');
data.append('page', '1');
data.append('limit', '10');

var config = {
  method: 'post',
  url: 'https://domain-open-api.cuiqiu.com/v1/box/list',
  headers: { 
    ...data.getHeaders()
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

获取邮件详细

var axios = require('axios');
var FormData = require('form-data');
var data = new FormData();
data.append('mail_id', '08EJ98s9dWz');
data.append('token', 'f76a1b32bacc4279bd6b731e59d8hj8837');
data.append('box_id', '23094');

var config = {
  method: 'post',
  url: 'https://domain-open-api.cuiqiu.com/v1/box/detail',
  headers: { 
    ...data.getHeaders()
  },
  data : data
};

axios(config)
.then(function (response) {
  console.log(JSON.stringify(response.data));
})
.catch(function (error) {
  console.log(error);
});

XHR原始JS方式请求(适合无法安装框架,兼容性差的环境)

获取邮件列表

var data = new FormData();
data.append("mail_id", "nM5GLra9Wo");
data.append("token", "4dfd31985d7e417cb8062b402950efb0");
data.append("start_time", "2021-07-15");
data.append("end_time", "2021-07-16");
data.append("page", "1");
data.append("limit", "10");

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://domain-open-api.cuiqiu.com/v1/box/list");

xhr.send(data);

获取邮件详细

var data = new FormData();
data.append("mail_id", "08EJ98s9dWz");
data.append("token", "f76a1b32bacc4279bd6b731e59d8hj8837");
data.append("box_id", "23094");

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function() {
  if(this.readyState === 4) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://domain-open-api.cuiqiu.com/v1/box/detail");

xhr.send(data);

jQuery方式请求

获取邮件列表

var form = new FormData();
form.append("mail_id", "nM5GLra9Wo");
form.append("token", "4dfd31985d7e417cb8062b402950efb0");
form.append("start_time", "2021-07-15");
form.append("end_time", "2021-07-16");
form.append("page", "1");
form.append("limit", "10");

var settings = {
  "url": "https://domain-open-api.cuiqiu.com/v1/box/list",
  "method": "POST",
  "timeout": 0,
  "processData": false,
  "mimeType": "multipart/form-data",
  "contentType": false,
  "data": form
};

$.ajax(settings).done(function (response) {
  console.log(response);
});

获取邮件详细

var form = new FormData();
form.append("mail_id", "08EJ98s9dWz");
form.append("token", "f76a1b32bacc4279bd6b731e59d8hj8837");
form.append("box_id", "23094");

var settings = {
  "url": "https://domain-open-api.cuiqiu.com/v1/box/detail",
  "method": "POST",
  "timeout": 0,
  "processData": false,
  "mimeType": "multipart/form-data",
  "contentType": false,
  "data": form
};

$.ajax(settings).done(function (response) {
  console.log(response);
});

Request方式请求(适合nodejs环境)

获取邮件列表

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://domain-open-api.cuiqiu.com/v1/box/list',
  'headers': {
  },
  formData: {
    'mail_id': 'nM5GLra9Wo',
    'token': '4dfd31985d7e417cb8062b402950efb0',
    'start_time': '2021-07-15',
    'end_time': '2021-07-16',
    'page': '1',
    'limit': '10'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

获取邮件详细

var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://domain-open-api.cuiqiu.com/v1/box/detail',
  'headers': {
  },
  formData: {
    'mail_id': '08EJ98s9dWz',
    'token': 'f76a1b32bacc4279bd6b731e59d8hj8837',
    'box_id': '23094'
  }
};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});

 

我的域名绑定企业微信或者阿里邮箱了,是否可以继续使用脆球邮箱?

脆球邮箱主要用于账号注册,而非工作邮箱,您可以把二级域名作为脆球邮箱使用。 比如您购买的域名是:abc.com […]