chore: 并入 iotlcm-sms 历史到 sms/(原提交 1d38bc4)
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
func main() {
|
||||
endpoint := "http://127.0.0.1:8080/api/v1/sms/send"
|
||||
if len(os.Args) > 1 {
|
||||
endpoint = os.Args[1]
|
||||
}
|
||||
|
||||
// 阿里云 msgContent 是模板参数 JSON;请替换为测试账号、签名和模板。
|
||||
body := []byte(`{
|
||||
"config": {
|
||||
"serviceType": "1",
|
||||
"regionId": "cn-hangzhou",
|
||||
"accessKeyId": "your-access-key-id",
|
||||
"accessKeySecret": "your-access-key-secret",
|
||||
"signName": "your-sign-name",
|
||||
"templateId": "SMS_000000001"
|
||||
},
|
||||
"params": {
|
||||
"phoneNumber": "13800008000",
|
||||
"msgContent": "{\"code\":\"123456\"}"
|
||||
}
|
||||
}`)
|
||||
|
||||
response, err := http.Post(endpoint, "application/json", bytes.NewReader(body))
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
defer response.Body.Close()
|
||||
responseBody, err := io.ReadAll(response.Body)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Printf("HTTP %d\n%s", response.StatusCode, responseBody)
|
||||
}
|
||||
Reference in New Issue
Block a user