| Author | SHA1 | Message | Date |
|---|---|---|---|
|
|
3fcf8d8aa0 | 百世云短信 | 1 year ago |
|
|
006a73e54a | 修改创蓝地址,修改UMS返回参数 | 2 years ago |
|
|
88657cb9ad | 增加创蓝短信发送接口 | 2 years ago |
| @ -0,0 +1,56 @@ | |||
| package sms | |||
| import ( | |||
| "log" | |||
| "git.tetele.net/tgo/helper" | |||
| ) | |||
| /* | |||
| * | |||
| - 百世云发送短信 | |||
| * | |||
| - @param string $sp_id sp_id | |||
| - @param string $password 密码 | |||
| - @param string $mobile 手机号码 | |||
| - @param string $content 短信内容 | |||
| - @param string $sms_sign 短信签名 | |||
| - @return success bool, reply map[string]string, err error | |||
| */ | |||
| func SendByBaishiy(sp_id, password, mobile, sms_sign, content string) (bool, map[string]interface{}, error) { | |||
| url := "http://124.220.34.130:9511/api/send-sms-single" | |||
| //创蓝接口参数 | |||
| data := map[string]string{ | |||
| "sp_id": sp_id, | |||
| "password": password, | |||
| "content": StringJoin("【", sms_sign, "】", content), | |||
| "mobile": mobile, | |||
| } | |||
| response, err := SendHttp("POST", url, data) | |||
| if err != nil { | |||
| return false, nil, err | |||
| } | |||
| var reply map[string]interface{} | |||
| err = json.Unmarshal(response, &reply) | |||
| if err != nil { | |||
| log.Println(string(response), err) | |||
| return false, nil, err | |||
| } | |||
| if helper.ToStr(reply["code"]) != "0" { | |||
| return false, reply, nil | |||
| } | |||
| return true, reply, err | |||
| } | |||
| @ -0,0 +1,14 @@ | |||
| package sms | |||
| import ( | |||
| "testing" | |||
| ) | |||
| func Test_SendByBaishiy(t *testing.T) { | |||
| msg := "罗您好,您的商店新增2单物理灭蚊仪-天眼款,请及时登录商家后台处理!" | |||
| ret, reply, err := SendByBaishiy("991422", "f3012ddbaa069ba58dd94ec28e35f214", "13631270978", "园圈", msg) | |||
| t.Log(ret) | |||
| t.Log(reply) | |||
| t.Log(err) | |||
| } | |||
| @ -0,0 +1,109 @@ | |||
| package sms | |||
| import ( | |||
| "log" | |||
| "git.tetele.net/tgo/helper" | |||
| ) | |||
| /** | |||
| * 创蓝253发送短信 | |||
| * | |||
| * @param string $mobile 手机号码 | |||
| * @param string $msg 短信内容 | |||
| * @param string $sms_sign 短信签名 | |||
| * @param string $needstatus 是否需要状态报告 | |||
| * @return success bool, reply map[string]string, err error | |||
| */ | |||
| var CL_ACCOUNT string = "N3402351" | |||
| var CL_PASSWORD string = "zmkj64U5A" | |||
| // const CL_VARIABLE_SMS_URL string = "http://XXX/msg/variable/json" | |||
| func SendByCL(account, password, mobile, sms_sign, msg string) (bool, map[string]interface{}, error) { | |||
| const CL_SIMPLE_SMS_URL string = "https://smssh1.253.com/msg/v1/send/json" // "http://smssh1.253.com/msg/send/json" | |||
| if account == "" { | |||
| account = CL_ACCOUNT | |||
| } | |||
| if password == "" { | |||
| password = CL_PASSWORD | |||
| } | |||
| //创蓝接口参数 | |||
| data := map[string]string{ | |||
| "account": account, | |||
| "password": password, | |||
| "msg": StringJoin("【", sms_sign, "】", msg), | |||
| "phone": mobile, | |||
| "report": "true", | |||
| } | |||
| response, err := PostJsonData(CL_SIMPLE_SMS_URL, data) | |||
| if err != nil { | |||
| return false, nil, err | |||
| } | |||
| var reply map[string]interface{} | |||
| err = json.Unmarshal(response, &reply) | |||
| if err != nil { | |||
| log.Println(string(response), err) | |||
| return false, nil, err | |||
| } | |||
| if helper.ToStr(reply["code"]) != "0" { | |||
| return false, reply, nil | |||
| } | |||
| return true, reply, err | |||
| } | |||
| /** | |||
| * 查询额度 | |||
| * | |||
| */ | |||
| func QueryRemaining(account, password string) (bool, string, map[string]interface{}, error) { | |||
| const URL string = "https://smssh1.253.com/msg/balance/json" | |||
| if account == "" { | |||
| account = CL_ACCOUNT | |||
| } | |||
| if password == "" { | |||
| password = CL_PASSWORD | |||
| } | |||
| data := map[string]string{ | |||
| "account": account, | |||
| "password": password, | |||
| } | |||
| response, err := PostJsonData(URL, data) | |||
| /** 返回示例 | |||
| {"code":0,"balance":"9156","time":"20230217150940","errorMsg":""} | |||
| {"code":"130","msgId":"","time":"20230217145243","errorMsg":"请求参数错误"} | |||
| {"code":"101","msgId":"","time":"20230217151029","errorMsg":"无此用户"} | |||
| */ | |||
| if err != nil { | |||
| return false, "", nil, err | |||
| } | |||
| var reply map[string]interface{} | |||
| err = json.Unmarshal(response, &reply) | |||
| if err != nil { | |||
| log.Println(string(response), err) | |||
| return false, "", nil, err | |||
| } | |||
| if helper.ToStr(reply["code"]) != "0" { | |||
| return false, "", reply, nil | |||
| } | |||
| return true, helper.ToStr(reply["balance"]), reply, err | |||
| } | |||
| @ -0,0 +1,24 @@ | |||
| package sms | |||
| import ( | |||
| "testing" | |||
| ) | |||
| func Test_SendByCL(t *testing.T) { | |||
| msg := "罗您好,您的商店新增2单物理灭蚊仪-天眼款,请及时登录商家后台处理!" | |||
| //ret, reply, err := SendByCL("", "", "13631270978", "平沙数字云店", msg) | |||
| ret, reply, err := SendByCL("", "", "13631270978", "园圈", msg) | |||
| t.Log(ret) | |||
| t.Log(reply) | |||
| t.Log(err) | |||
| } | |||
| func Test_QueryRemaining(t *testing.T) { | |||
| ret, total, reply, err := QueryRemaining("", "") | |||
| t.Log(ret) | |||
| t.Log(total) | |||
| t.Log(reply) | |||
| t.Log(err) | |||
| } | |||
| @ -0,0 +1,28 @@ | |||
| package sms | |||
| import ( | |||
| "testing" | |||
| ) | |||
| func Test_SendByTencent(t *testing.T) { | |||
| secretId := "AKIDObaKq9NRFn6A2iBaOxGKBoqeEbjdT5Vg" | |||
| secretKey := "0mLiqlU0IMwIOEqGWYMxLVREsMelhT3R" | |||
| smsAppId := "1400705248" | |||
| signname := "智企易创" | |||
| mobiles := []string{"18607565510"} | |||
| templateId := "1478144" | |||
| params := []string{"666555", "5"} | |||
| requestId, status, err := SendByTencent(secretId, secretKey, smsAppId, signname, mobiles, templateId, params, "ap-beijing") | |||
| t.Log(*requestId) | |||
| if len(status) > 0 { | |||
| for _, v := range status { | |||
| t.Log(*v.SerialNo, *v.PhoneNumber, *v.Code, *v.Message, *v.Fee, *v.SessionContext, *v.IsoCode) | |||
| } | |||
| } | |||
| t.Log(err) | |||
| } | |||