本文為您提供了Go語言版本的語音驗證碼發(fā)送接口對接DEMO示例
//測試:go run ./test.go
package main
import (
"fmt"
"io/ioutil"
"net/http"
"net/url"
"strings"
)
const strUrl = "https://api.ihuyi.com/voice/Submit.json"
func main() {
v := url.Values{}
v.Set("account", "xxxxxxxx") //APIID(用戶中心【云語音】-【語音驗證碼】-【產(chǎn)品總覽】查看)
v.Set("password", "xxxxxxxxx") //1、APIKEY(用戶中心【云語音】-【語音驗證碼】-【產(chǎn)品總覽】查看)
2、動態(tài)密碼(生成動態(tài)密碼方式請看該文檔末尾的說明)
v.Set("mobile", "136xxxxxxxx") //接收手機號碼,只能提交1個號碼
v.Set("content", "832745") //驗證碼(4-6位數(shù)字)
v.Set("time", "1623643787") //Unix時間戳(10位整型數(shù)字,當使用動態(tài)密碼方式時為必填)
body := strings.NewReader(v.Encode()) //把form數(shù)據(jù)編碼
client := &http.Client{}
req, _ := http.NewRequest("POST", strUrl, body)
req.Header.Set("Content-Type", "application/x-www-form-urlencoded")
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ù)咨詢(非工作時間):
售后咨詢(非工作時間):
驗證碼已發(fā)送到您的手機,請查收!
輸入驗證碼后,點擊“開通體驗賬戶”按鈕可立即開通體驗賬戶。