chore: 初始开源发布
iotlcm-sms:独立短信 HTTP/gRPC 服务,支持阿里云与腾讯云。 - Go module 迁移至 git.5iot.com/iotlcm-public/iotlcm-sms - 补 Apache-2.0 LICENSE,重写 README(特性/配置/接口/部署/目录/测试) - 配置改为 config.example.yaml + SMS_* 环境变量注入,仓库不含真实凭证 - 清理内部标识(私有镜像仓库 / 公司名 / 客户签名 / 真实模板ID / 真实手机号) - 统一 LF 行尾并加 .gitattributes
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": "138****8000",
|
||||
"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