|
|
@ -0,0 +1,54 @@ |
|
|
|
package smsrpc |
|
|
|
|
|
|
|
import ( |
|
|
|
"encoding/json" |
|
|
|
"errors" |
|
|
|
"log" |
|
|
|
) |
|
|
|
|
|
|
|
func SendWoSms(cpcode, key string, msg, mobiles string, excode, templetId 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 |
|
|
|
|
|
|
|
} |