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
|
|
|
|
}
|