短信rpc
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
1.1 KiB

package smsrpc
import (
"encoding/json"
"errors"
"log"
)
/**
* 发送联通融合通信短信
* @cpcode 商户编号
* @key accessKey
* @excode 扩展码
* @mobiles 手机号,多个用逗号隔开
* @templetId 模板id
* @msg 模板中变量的值,如果包含多个参数,以半角英文逗号分隔
*/
func SendWoSms(cpcode, key string, excode, mobiles string, templetId, msg string, url ...string) (map[string]interface{}, error) {
if cpcode == "" || key == "" {
return nil, errors.New("参数错误")
}
conn, err := rpc_server_conn(url...)
if err != nil {
return nil, err
}
defer conn.Close()
arg := WoParam{cpcode, msg, mobiles, excode, templetId, key}
req, err := SetReqData(arg)
if err != nil {
return nil, err
}
res := &Response{}
err = conn.SendWoMsg(req, res)
if err != nil {
return nil, err
}
res_data_de, err := GetResData(res)
log.Println(res_data_de, err)
if err != nil {
return nil, err
}
if res_data_de == "" {
return nil, nil
}
var res_arr map[string]interface{}
err = json.Unmarshal([]byte(res_data_de), &res_arr)
if err != nil {
return nil, err
}
return res_arr, nil
}