代码拉取完成,页面将自动刷新
package jpush
import (
"encoding/json"
"fmt"
)
type CidRequest struct {
Count int `json:"count,omitempty"` // 数值类型,不传则默认为 1。范围为 [1, 1000]
Type string `json:"type,omitempty"` // CID 类型。取值:push(默认),schedule
}
type CidResponse struct {
CidList []string `json:"cidlist,omitempty"` // CID 列表
}
func (c CidRequest) String() string {
return fmt.Sprintf("CidRequest{Count: %d, Type: %s}", c.Count, c.Type)
}
func (c CidResponse) String() string {
return fmt.Sprintf("CidResponse{CidList: %v}", c.CidList)
}
// NewCidRequest 创建 CidRequest 对象
func NewCidRequest(count int, push_type string) *CidRequest {
c := &CidRequest{}
if count <= 0 || count > 1000 {
c.Count = 1
} else {
c.Count = count
}
if push_type == "" {
c.Type = "push"
} else {
c.Type = push_type
}
return c
}
// GetCidList 获取 CID 列表
func (c *CidRequest) GetCidList(key, secret string) (*CidResponse, error) {
resp := &CidResponse{}
jc := NewJPushClient(key, secret)
data, err := jc.GetCid(c.Count, c.Type)
if err != nil {
return nil, err
}
fmt.Printf("%+v\n", string(data))
err = json.Unmarshal(data, resp)
return resp, err
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。