天天看点

个推推送工具

package getui

import (
    "encoding/json"
    "log"
    "net/http"

    "github.com/gin-gonic/gin"
)

//https://docs.getui.com/getui/server/rest_v2/push/
// unipush
const APPID = ""
const BASEURL = "https://restapi.getui.com/v2/" + APPID
const APPKEY = ""
const APPSECRET = ""
const MASTERSECRET = ""

var TokenValue = "741d3ee3fc928183a7ed99a0c10556bc0452b8a6b94189751cc6a46120e923ae"

func Tuisong(c *gin.Context) {
    // pall()
    // ObtainToken()
    // ziji
    // TestSingle("3d370427e148ea1b3be094b084360ee8")
    // xiaoyi
    // TestSingle("0a4c02db3a735ecefa26e2deb71a9d74")

    c.JSON(http.StatusOK, gin.H{"message": "tuisong_ok"})
}

func JsonToStruct() {
    jsonStr := `{"code": 105,"msg": "haliluya","data": {"expire_time": "123","token": "678"}}`
    tr := TokenResult{}
    err := json.Unmarshal([]byte(jsonStr), &tr)
    if err != nil {
        log.Println(err)
    }
    log.Println(tr.Msg)
}

type Audience struct {
    Cid []string
}
type Notification struct {
    Title      string
    Body       string
    Click_type string
}
type Push_message struct {
    Notification Notification
}

type PushResult struct {
    Code int64
    Msg  string
}
type Single struct {
    Request_id   string
    Audience     Audience
    Push_message Push_message
}