1. 获取token
package main

import (
"fmt"
"net/http"
"io/ioutil"
)

func main() {

url := "https://www.lmparcel.com/custom-api/api/accessToken?username=&password="
method := "GET"

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

if err != nil {
fmt.Println(err)
return
}
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. 创建订单
package main

import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)

func main() {

url := "https://www.lmparcel.com/custom-api/api/createOrder"
method := "POST"

payload := strings.NewReader(`{`+"
"+`
"token": "",`+"
"+`
"customerCode": "",`+"
"+`
"returnSign": "N",`+"
"+`
"customerInvoiceCode": "93778602",`+"
"+`
"tradeType": "ZYXT",`+"
"+`
"countryCode": "US",`+"
"+`
"productId": 6008,`+"
"+`
"transactionUrl": "https://www.amazon.com/gp/product/B07Q8RJSG7",`+"
"+`
"currencyCode": "USD",`+"
"+`
"consigneeName": "Lorenzo Martin Del Campo Alvarado",`+"
"+`
"consigneeAddress": "1538 SEDALIA WAY.",`+"
"+`
"consigneeCity": "AURORA",`+"
"+`
"consigneePostCode": "80011-5013",`+"
"+`
"consigneeState": "CO",`+"
"+`
"consigneeTelephone": "7203817764",`+"
"+`
"consigneeMobile": "13266829617",`+"
"+`
"consigneeEmail": "zhc_hnus.com",`+"
"+`
"consigneeCompanyName": "Lorenzo rado",`+"
"+`
"shipperName": "Mr Zhang",`+"
"+`
"shipperCompanyName": "Haiky",`+"
"+`
"shipperAddress1": "3",`+"
"+`
"shipperCity": "S",`+"
"+`
"shipperState": "G
"shipperPostCode": "",`+"
"+`
"shipperCountry": "CN",`+"
"+`
"shipperTelephone": "",`+"
"+`
"orderInvoices": [{`+"
"+`
"invoiceAmount": 7.1,`+"
"+`
"invoicePcs": 1,`+"
"+`
"skuNameCn": "Galaxy watch active保护壳黑色40mm 1片装",`+"
"+`
"skuNameEn": "watch cover",`+"
"+`
"skuCode": "GWAEBHK2",`+"
"+`
"hsCode": "",`+"
"+`
"invoicePurpose": "手机保护装置"`+"
"+`
}]`+"
"+`
}`)

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

if err != nil {
fmt.Println(err)
return
}
req.Header.Add("Content-Type", "application/json")

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))
}