97 lines
2.1 KiB
Go
97 lines
2.1 KiB
Go
package tencent_test
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"fmt"
|
|
"testing"
|
|
|
|
"code.yun.ink/pkg/smsx/entity"
|
|
"code.yun.ink/pkg/smsx/interfaces"
|
|
"code.yun.ink/pkg/smsx/tencent"
|
|
"github.com/yuninks/loggerx"
|
|
)
|
|
|
|
// SecretId: "AKID73nQvEex74oGVcWCmJeltvpVxBCzvc5L",
|
|
// SecretKey: "CB378ye8QdfT2Yt2zmTyFJ9k7MYsKwW2",
|
|
// SignName: "破德商贸",
|
|
// SmsSdkAppId: "1400932084",
|
|
|
|
// SecretId: "AKIDcWYTFrKdoLpBLLDvUtjCWgiaIsJaihOn",
|
|
// SecretKey: "gOVa2NZbTFtN7tnUicdffbwq0w1ZEB6e",
|
|
// SignName: "永济彭俊网络科技有限公司",
|
|
// SmsSdkAppId: "1400908293",
|
|
|
|
func TestGetTemp(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
logger := loggerx.NewLogger(ctx)
|
|
|
|
ten := tencent.Tencent{}
|
|
|
|
ini, err := ten.InitSmsx(ctx, consts.SmsConfigData{
|
|
SysType: consts.Platform3rdTypeTencent,
|
|
Tencent: &consts.SmsConfigDataTencent{
|
|
SecretId: "AKIDb2b8SefT8YjgUBk8N0XtANMSZWFqLiIp",
|
|
SecretKey: "QxqstqipqkTzfKqGVdgr3Merx0uvoU3R",
|
|
SignName: "深圳宏建源贸易",
|
|
SmsSdkAppId: "1400883795",
|
|
},
|
|
}, logger)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
resp, err := ini.GetTemp(ctx)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
b, _ := json.Marshal(resp)
|
|
|
|
logger.Infof(ctx, "sssss %s", string(b))
|
|
|
|
fmt.Println("sssss", string(b))
|
|
|
|
t.Log(resp)
|
|
}
|
|
|
|
func TestSend(t *testing.T) {
|
|
ctx := context.Background()
|
|
|
|
logger := loggerx.NewLogger(ctx)
|
|
|
|
ten := tencent.Tencent{}
|
|
|
|
// Tencent: &model.SmsConfigDataTencent{
|
|
// SecretId: "AKID73nQvEex74oGVcWCmJeltvpVxBCzvc5L",
|
|
// SecretKey: "CB378ye8QdfT2Yt2zmTyFJ9k7MYsKwW2",
|
|
// SignName: "破德商贸",
|
|
// SmsSdkAppId: "1400932084",
|
|
// },
|
|
|
|
ini, err := ten.InitSmsx(ctx, consts.SmsConfigData{
|
|
SysType: consts.Platform3rdTypeTencent,
|
|
Tencent: &consts.SmsConfigDataTencent{
|
|
SecretId: "AKIDb2b8SefT8YjgUBk8N0XtANMSZWFqLiIp",
|
|
SecretKey: "QxqstqipqkTzfKqGVdgr3Merx0uvoU3R",
|
|
SignName: "深圳宏建源贸易",
|
|
SmsSdkAppId: "1400883795",
|
|
},
|
|
},logger)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
err = ini.Send(ctx, "2060882", "+85267369217", []interfaces.SmsSendParam{
|
|
{
|
|
Field: "1",
|
|
Value: "123456",
|
|
},
|
|
})
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
t.Log("success")
|
|
|
|
}
|