//測試:go run ./test.go
package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
const strUrl = "https://api.ihuyi.com/empty-number/submit"
func main() {
params := map[string]interface{}{
"mobiles": []string{"18800000000", "18800000002"}, //手機號數(shù)組(最多10個)
}
//將params轉(zhuǎn)成json字符串
jsonBody, err := json.Marshal(params)
if err != nil {
fmt.Println("JSON轉(zhuǎn)換錯誤:", err)
return
}
body := string(jsonBody)
client := &http.Client{}
req, _ := http.NewRequest("POST", strUrl, strings.NewReader(body))
req.Header.Set("Content-Type", "application/json; charset=utf-8") //form表單提交
req.Header.Set("Date", "Tue, 26 Aug 2025 07:14:23 GMT; charset=utf-8") // 請?zhí)鎿Q為當(dāng)前的GMT時間,可參考:https://gitee.com/shsurlink/api-demo/blob/master/hmac-auth/go/main.go
req.Header.Set("Authorization", "Signature xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx; charset=utf-8") //請?zhí)鎿Q為您的鑒權(quán)簽名,可參考:https://gitee.com/shsurlink/api-demo/blob/master/hmac-auth/go/main.go
resp, err := client.Do(req) //發(fā)送
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close() //一定要關(guān)閉resp.Body
res, _ := ioutil.ReadAll(resp.Body)
fmt.Println(string(res))
}
國內(nèi)專業(yè)互聯(lián)網(wǎng)團隊
21年行業(yè)經(jīng)驗
7x24小時售后支持
豐富的行業(yè)經(jīng)驗
Copyright ? 2004-2025 上海思銳信息技術(shù)有限公司 All rights reserved. 滬ICP備07035915號-15 電信增值業(yè)務(wù)許可證:B2-20160082
服務(wù)熱線:
4008 808 898
服務(wù)熱線(工作時間):
4008 808 898
業(yè)務(wù)咨詢(非工作時間):
售后咨詢(非工作時間):