Golang语言API请求示例

获取邮件列表

package main

import (
  "fmt"
  "bytes"
  "mime/multipart"
  "net/http"
  "io/ioutil"
)

func main() {

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

  payload := &bytes.Buffer{}
  writer := multipart.NewWriter(payload)
  _ = writer.WriteField("mail_id", "nM5GLra9Wo")
  _ = writer.WriteField("token", "4dfd31985d7e417cb8062b402950efb0")
  _ = writer.WriteField("start_time", "2021-07-15")
  _ = writer.WriteField("end_time", "2021-07-16")
  _ = writer.WriteField("page", "1")
  _ = writer.WriteField("limit", "10")
  err := writer.Close()
  if err != nil {
    fmt.Println(err)
    return
  }


  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Set("Content-Type", writer.FormDataContentType())
  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

 

获取邮件详细

package main

import (
  "fmt"
  "bytes"
  "mime/multipart"
  "net/http"
  "io/ioutil"
)

func main() {

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

  payload := &bytes.Buffer{}
  writer := multipart.NewWriter(payload)
  _ = writer.WriteField("mail_id", "08EJ98s9dWz")
  _ = writer.WriteField("token", "f76a1b32bacc4279bd6b731e59d8hj8837")
  _ = writer.WriteField("box_id", "23094")
  err := writer.Close()
  if err != nil {
    fmt.Println(err)
    return
  }


  client := &http.Client {
  }
  req, err := http.NewRequest(method, url, payload)

  if err != nil {
    fmt.Println(err)
    return
  }
  req.Header.Set("Content-Type", writer.FormDataContentType())
  res, err := client.Do(req)
  if err != nil {
    fmt.Println(err)
    return
  }
  defer res.Body.Close()

  body, err := ioutil.ReadAll(res.Body)
  if err != nil {
    fmt.Println(err)
    return
  }
  fmt.Println(string(body))
}

 

为什么我的脆球邮箱收不到邮件?

1、排查收件方 2、排查发件方