|
|
@@ -7,12 +7,13 @@ import ( |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"github.com/syyongx/php2go" |
|
|
|
"github.com/tidwall/gjson" |
|
|
|
) |
|
|
|
|
|
|
|
func Send(appKey, appSecret string, param md.PushParam) (interface{}, error) { |
|
|
|
func Send(appKey, appSecret string, param md.PushParam) (string, error) { |
|
|
|
|
|
|
|
if appKey == "" || appSecret == "" { |
|
|
|
return nil, errors.New("配置未设置") |
|
|
|
return "", errors.New("配置未设置") |
|
|
|
} |
|
|
|
url := "https://api.jpush.cn/v3/push" |
|
|
|
var iosAlert = md.PushIosAlert{Title: param.Title, Body: param.Content} |
|
|
@@ -54,12 +55,16 @@ func Send(appKey, appSecret string, param md.PushParam) (interface{}, error) { |
|
|
|
} |
|
|
|
b, err := json.Marshal(req) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return "", err |
|
|
|
} |
|
|
|
res, err := jg_push_utils.CurlPost(url, b, headers) |
|
|
|
if err != nil { |
|
|
|
return nil, err |
|
|
|
return "", err |
|
|
|
} |
|
|
|
fmt.Println(res) |
|
|
|
return res, nil |
|
|
|
fmt.Println(string(res)) |
|
|
|
msgId := gjson.Get(string(res), "msg_id").String() |
|
|
|
if msgId == "0" || msgId == "" { |
|
|
|
return "", err |
|
|
|
} |
|
|
|
return msgId, nil |
|
|
|
} |