Bladeren bron

add reverse:for v1.0.1 极光推送

tags/v1.0.1
huangjiajun 2 jaren geleden
bovenliggende
commit
c0ea9b4b5a
3 gewijzigde bestanden met toevoegingen van 21 en 7 verwijderingen
  1. +4
    -1
      go.mod
  2. +6
    -0
      go.sum
  3. +11
    -6
      hdl/jg_push.go

+ 4
- 1
go.mod Bestand weergeven

@@ -2,4 +2,7 @@ module code.fnuoos.com/go_rely_warehouse/zyos_go_jg_push.git

go 1.15

require github.com/syyongx/php2go v0.9.7
require (
github.com/syyongx/php2go v0.9.7
github.com/tidwall/gjson v1.14.1
)

+ 6
- 0
go.sum Bestand weergeven

@@ -1,2 +1,8 @@
github.com/syyongx/php2go v0.9.7 h1:boZtLbm2xYbW49mX9M7Vq2zkVhBhv3fCqs2T16d2bGA=
github.com/syyongx/php2go v0.9.7/go.mod h1:meN2eIhhUoxOd2nMxbpe8g6cFPXI5O9/UAAuz7oDdzw=
github.com/tidwall/gjson v1.14.1 h1:iymTbGkQBhveq21bEvAQ81I0LEBork8BFe1CUZXdyuo=
github.com/tidwall/gjson v1.14.1/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
github.com/tidwall/pretty v1.2.0 h1:RWIZEg2iJ8/g6fDDYzMpobmaoGh5OLl4AXtGUGPcqCs=
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=

+ 11
- 6
hdl/jg_push.go Bestand weergeven

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

Laden…
Annuleren
Opslaan