Documentation ¶
Overview ¶
Copyright 2015 Beijing Venusource Tech.Co.Ltd. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
一些常量
Copyright 2015 Beijing Venusource Tech.Co.Ltd. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
封装了http调用相关的一些方法
Copyright 2015 Beijing Venusource Tech.Co.Ltd. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
百度云推送 SDK go语言版本
Copyright 2015 Beijing Venusource Tech.Co.Ltd. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Rest Api请求参数构造 ¶
Copyright 2015 Beijing Venusource Tech.Co.Ltd. All rights reserved. Use of this source code is governed by a BSD-style license that can be found in the LICENSE file.
Rest Api返回值封装
Index ¶
- Constants
- func CallApiServer(httpMethod string, server string, class string, method string, ...) error
- type AddDevicesToTagJSONResponse
- type AddDevicesToTagRequest
- type AddDevicesToTagResponse
- type AndroidNotification
- type BaiduPushClient
- func (c *BaiduPushClient) AddDevicesToTag(request AddDevicesToTagRequest) (*AddDevicesToTagResponse, error)
- func (c *BaiduPushClient) CancelTimerJob(timerId string) (*CancelTimerJobResponse, error)
- func (c *BaiduPushClient) CreateTag(request CreateTagRequest) (*CreateTagResponse, error)
- func (c *BaiduPushClient) Debug(enabled bool)
- func (c *BaiduPushClient) DeleteDevicesFromTag(request DeleteDevicesFromTagRequest) (*DeleteDevicesFromTagResponse, error)
- func (c *BaiduPushClient) DeleteTag(request DeleteTagRequest) (*DeleteTagResponse, error)
- func (c *BaiduPushClient) PushBatchUniMsg(request PushBatchUniMsgRequest) (*PushBatchUniMsgResponse, error)
- func (c *BaiduPushClient) PushMsgToAllDevice(request PushMsgToAllRequest) (*PushMsgToAllResponse, error)
- func (c *BaiduPushClient) PushMsgToSingleDevice(request PushMsgToSingleDeviceRequest) (*PushMsgToSingleDeviceResponse, error)
- func (c *BaiduPushClient) PushMsgToTag(request PushMsgToTagRequest) (*PushMsgToTagResponse, error)
- func (c *BaiduPushClient) QueryDeviceNumInTag(request QueryDeviceNumInTagRequest) (*QueryDeviceNumInTagResponse, error)
- func (c *BaiduPushClient) QueryMsgStatus(request QueryMsgStatusRequest) (*QueryMsgStatusResponse, error)
- func (c *BaiduPushClient) QueryStatisticDevice() (*QueryStatisticDeviceResponse, error)
- func (c *BaiduPushClient) QueryStatisticTopic(request QueryStatisticTopicRequest) (*QueryStatisticTopicResponse, error)
- func (c *BaiduPushClient) QueryTags(request QueryTagsRequest) (*QueryTagsResponse, error)
- func (c *BaiduPushClient) QueryTimerList(request QueryTimerListRequest) (*QueryTimerListResponse, error)
- func (c *BaiduPushClient) QueryTimerRecords(request QueryTimerRecordsRequest) (*QueryTimerRecordsResponse, error)
- func (c *BaiduPushClient) QueryTopicList(request QueryTopicListRequest) (*QueryTopicListResponse, error)
- func (c *BaiduPushClient) QueryTopicRecords(request QueryTopicRecordsRequest) (*QueryTopicRecordsResponse, error)
- type CancelTimerJobResponse
- type CreateTagJSONResponse
- type CreateTagRequest
- type CreateTagResponse
- type DeleteDevicesFromTagJSONResponse
- type DeleteDevicesFromTagRequest
- type DeleteDevicesFromTagResponse
- type DeleteTagJSONResponse
- type DeleteTagRequest
- type DeleteTagResponse
- type DeviceInfo
- type DeviceStatUnit
- type ErrorResponse
- type MsgSendInfo
- type OrderedParams
- func (o *OrderedParams) Add(key, value string)
- func (o *OrderedParams) AddUnescaped(key, value string)
- func (o *OrderedParams) Clone() *OrderedParams
- func (o *OrderedParams) Get(key string) string
- func (o *OrderedParams) Keys() []string
- func (o *OrderedParams) Len() int
- func (o *OrderedParams) Less(i int, j int) bool
- func (o *OrderedParams) Swap(i int, j int)
- type PushBatchUniMsgJSONResponse
- type PushBatchUniMsgRequest
- type PushBatchUniMsgResponse
- type PushMsgToAllJSONResponse
- type PushMsgToAllRequest
- type PushMsgToAllResponse
- type PushMsgToSingleDeviceJSONResponse
- type PushMsgToSingleDeviceRequest
- type PushMsgToSingleDeviceResponse
- type PushMsgToTagJSONResponse
- type PushMsgToTagRequest
- type PushMsgToTagResponse
- type QueryDeviceNumInTagJSONResponse
- type QueryDeviceNumInTagRequest
- type QueryDeviceNumInTagResponse
- type QueryMsgStatusJSONResponse
- type QueryMsgStatusRequest
- type QueryMsgStatusResponse
- type QueryStatisticDeviceJSONResponse
- type QueryStatisticDeviceResponse
- type QueryStatisticTopicJSONResponse
- type QueryStatisticTopicRequest
- type QueryStatisticTopicResponse
- type QueryTagsJSONResponse
- type QueryTagsRequest
- type QueryTagsResponse
- type QueryTimerListJSONResponse
- type QueryTimerListRequest
- type QueryTimerListResponse
- type QueryTimerRecordsJSONResponse
- type QueryTimerRecordsRequest
- type QueryTimerRecordsResponse
- type QueryTopicListJSONResponse
- type QueryTopicListRequest
- type QueryTopicListResponse
- type QueryTopicRecordsJSONResponse
- type QueryTopicRecordsRequest
- type QueryTopicRecordsResponse
- type Record
- type TagInfo
- type TimerResultInfo
- type TopicResultInfo
- type TopicStatUnit
Constants ¶
const (
API_SERVER = "http://api.tuisong.baidu.com/rest/3.0/"
)
Variables ¶
This section is empty.
Functions ¶
func CallApiServer ¶
func CallApiServer(httpMethod string, server string, class string, method string, params *OrderedParams, secretkey string, i interface{}) error
调用API
Types ¶
type AddDevicesToTagJSONResponse ¶
type AddDevicesToTagJSONResponse struct { RequestId int `json:"request_id"` AddDevicesToTagResponse AddDevicesToTagResponse `json:"response_params"` }
type AddDevicesToTagRequest ¶
func (*AddDevicesToTagRequest) AddToParams ¶
func (r *AddDevicesToTagRequest) AddToParams(params *OrderedParams) *OrderedParams
type AddDevicesToTagResponse ¶
type AddDevicesToTagResponse struct {
DevicesInfoAfterAdded []DeviceInfo `json:"devices"`
}
type AndroidNotification ¶
type AndroidNotification struct { Title string `json:"title"` //通知标题,可以为空;如果为空则设为appid对应的应用名; Description string `json:"description"` //通知文本内容,不能为空; NotificationBuilderId int `json:"notification_builder_id"` //android客户端自定义通知样式,如果没有设置默认为0; NotificationBasicStyle int `json:"notification_basic_style"` //只有notification_builder_id为0时有效,可以设置通知的基本样式包括(响铃:0x04;振动:0x02;可清除:0x01;),这是一个flag整形,每一位代表一种样式; OpenType int `json:"open_type"` //点击通知后的行为(1:打开Url; 2:自定义行为;3:默认打开应用;) Url string `json:"url"` //需要打开的Url地址,open_type为1时才有效; //open_type为2时才有效,Android端SDK会把pkg_content字符串转换成Android Intent, //通过该Intent打开对应app组件,所以pkg_content字符串格式必须遵循Intent uri格式,最简单的方法可以通过Intent方法toURI()获取 PkgContent string `json:"pkg_content"` CustomContent map[string]interface{} `json:"custom_content"` //自定义内容,键值对,Json对象形式(可选);在android客户端,这些键值对将以Intent中的extra进行传递。 }
Android通知消息,详见:http://push.baidu.com/doc/restapi/msg_struct
type BaiduPushClient ¶
type BaiduPushClient struct {
// contains filtered or unexported fields
}
调用API的Client
func NewClient ¶
func NewClient(apikey string, secretKey string) *BaiduPushClient
创建新的客户端
使用方法:
c = NewClient("API Key","Secret Key")
func (*BaiduPushClient) AddDevicesToTag ¶
func (c *BaiduPushClient) AddDevicesToTag(request AddDevicesToTagRequest) (*AddDevicesToTagResponse, error)
添加设备到标签组
func (*BaiduPushClient) CancelTimerJob ¶
func (c *BaiduPushClient) CancelTimerJob(timerId string) (*CancelTimerJobResponse, error)
取消定时任务
func (*BaiduPushClient) CreateTag ¶
func (c *BaiduPushClient) CreateTag(request CreateTagRequest) (*CreateTagResponse, error)
创建标签组
func (*BaiduPushClient) Debug ¶
func (c *BaiduPushClient) Debug(enabled bool)
func (*BaiduPushClient) DeleteDevicesFromTag ¶
func (c *BaiduPushClient) DeleteDevicesFromTag(request DeleteDevicesFromTagRequest) (*DeleteDevicesFromTagResponse, error)
将设备从标签组中移除
func (*BaiduPushClient) DeleteTag ¶
func (c *BaiduPushClient) DeleteTag(request DeleteTagRequest) (*DeleteTagResponse, error)
删除标签组
func (*BaiduPushClient) PushBatchUniMsg ¶
func (c *BaiduPushClient) PushBatchUniMsg(request PushBatchUniMsgRequest) (*PushBatchUniMsgResponse, error)
推送消息到给定的一组设备(批量单播)
func (*BaiduPushClient) PushMsgToAllDevice ¶
func (c *BaiduPushClient) PushMsgToAllDevice(request PushMsgToAllRequest) (*PushMsgToAllResponse, error)
推送广播消息
func (*BaiduPushClient) PushMsgToSingleDevice ¶
func (c *BaiduPushClient) PushMsgToSingleDevice(request PushMsgToSingleDeviceRequest) (*PushMsgToSingleDeviceResponse, error)
推送消息到单台设备
func (*BaiduPushClient) PushMsgToTag ¶
func (c *BaiduPushClient) PushMsgToTag(request PushMsgToTagRequest) (*PushMsgToTagResponse, error)
推送组播消息
func (*BaiduPushClient) QueryDeviceNumInTag ¶
func (c *BaiduPushClient) QueryDeviceNumInTag(request QueryDeviceNumInTagRequest) (*QueryDeviceNumInTagResponse, error)
查询标签组设备数量
func (*BaiduPushClient) QueryMsgStatus ¶
func (c *BaiduPushClient) QueryMsgStatus(request QueryMsgStatusRequest) (*QueryMsgStatusResponse, error)
查询消息的发送状态
func (*BaiduPushClient) QueryStatisticDevice ¶
func (c *BaiduPushClient) QueryStatisticDevice() (*QueryStatisticDeviceResponse, error)
当前应用的设备统计信息
func (*BaiduPushClient) QueryStatisticTopic ¶
func (c *BaiduPushClient) QueryStatisticTopic(request QueryStatisticTopicRequest) (*QueryStatisticTopicResponse, error)
查询分类主题统计信息
func (*BaiduPushClient) QueryTags ¶
func (c *BaiduPushClient) QueryTags(request QueryTagsRequest) (*QueryTagsResponse, error)
查询标签组列表
func (*BaiduPushClient) QueryTimerList ¶
func (c *BaiduPushClient) QueryTimerList(request QueryTimerListRequest) (*QueryTimerListResponse, error)
查询定时任务列表
func (*BaiduPushClient) QueryTimerRecords ¶
func (c *BaiduPushClient) QueryTimerRecords(request QueryTimerRecordsRequest) (*QueryTimerRecordsResponse, error)
查询定时消息的发送记录
func (*BaiduPushClient) QueryTopicList ¶
func (c *BaiduPushClient) QueryTopicList(request QueryTopicListRequest) (*QueryTopicListResponse, error)
查询分类主题列表
func (*BaiduPushClient) QueryTopicRecords ¶
func (c *BaiduPushClient) QueryTopicRecords(request QueryTopicRecordsRequest) (*QueryTopicRecordsResponse, error)
查询指定分类主题的发送记录
type CancelTimerJobResponse ¶
type CancelTimerJobResponse struct {
RequestId int `json:"request_id"`
}
type CreateTagJSONResponse ¶
type CreateTagJSONResponse struct { RequestId int `json:"request_id"` CreateTagResponse CreateTagResponse `json:"response_params"` }
type CreateTagRequest ¶
type CreateTagRequest struct {
TagName string
}
func (*CreateTagRequest) AddToParams ¶
func (r *CreateTagRequest) AddToParams(params *OrderedParams) *OrderedParams
type CreateTagResponse ¶
type DeleteDevicesFromTagJSONResponse ¶
type DeleteDevicesFromTagJSONResponse struct { RequestId int `json:"request_id"` DeleteDevicesFromTagResponse DeleteDevicesFromTagResponse `json:"response_params"` }
type DeleteDevicesFromTagRequest ¶
func (*DeleteDevicesFromTagRequest) AddToParams ¶
func (r *DeleteDevicesFromTagRequest) AddToParams(params *OrderedParams) *OrderedParams
type DeleteDevicesFromTagResponse ¶
type DeleteDevicesFromTagResponse struct {
DevicesInfoAfterDel []DeviceInfo `json:"devices"`
}
type DeleteTagJSONResponse ¶
type DeleteTagJSONResponse struct { RequestId int `json:"request_id"` DeleteTagResponse DeleteTagResponse `json:"response_params"` }
type DeleteTagRequest ¶
type DeleteTagRequest struct {
TagName string
}
func (*DeleteTagRequest) AddToParams ¶
func (r *DeleteTagRequest) AddToParams(params *OrderedParams) *OrderedParams
type DeleteTagResponse ¶
type DeviceInfo ¶
type DeviceStatUnit ¶
type ErrorResponse ¶
type ErrorResponse struct { RequestId int `json:"request_id"` //请求ID Code int `json:"error_code"` //服务端错误码 Message string `json:"error_msg"` //错误消息 }
服务器端错误返回信息
type MsgSendInfo ¶
type OrderedParams ¶
type OrderedParams struct {
// contains filtered or unexported fields
}
排序后的参数列表
func NewOrderedParams ¶
func NewOrderedParams() *OrderedParams
func (*OrderedParams) Add ¶
func (o *OrderedParams) Add(key, value string)
func (*OrderedParams) AddUnescaped ¶
func (o *OrderedParams) AddUnescaped(key, value string)
func (*OrderedParams) Clone ¶
func (o *OrderedParams) Clone() *OrderedParams
func (*OrderedParams) Get ¶
func (o *OrderedParams) Get(key string) string
func (*OrderedParams) Keys ¶
func (o *OrderedParams) Keys() []string
func (*OrderedParams) Len ¶
func (o *OrderedParams) Len() int
func (*OrderedParams) Swap ¶
func (o *OrderedParams) Swap(i int, j int)
type PushBatchUniMsgJSONResponse ¶
type PushBatchUniMsgJSONResponse struct { RequestId int `json:"request_id"` PushBatchUniMsgResponse PushBatchUniMsgResponse `json:"response_params"` }
type PushBatchUniMsgRequest ¶
type PushBatchUniMsgRequest struct { ChannelIds string //一组channel_id(最多为一万个)组成的json数组字符串 MsgType int //消息类型 0:消息;1:通知 Message string //消息内容,json格式, http://push.baidu.com/doc/restapi/msg_struct MsgExpires int //相对于当前时间的消息过期时间,单位为秒 默认为5小时(18000秒) TopicId string //分类主题名称 字母、数字及下划线组成,长度限制为1~128 }
func (*PushBatchUniMsgRequest) AddToParams ¶
func (r *PushBatchUniMsgRequest) AddToParams(params *OrderedParams) *OrderedParams
type PushBatchUniMsgResponse ¶
type PushMsgToAllJSONResponse ¶
type PushMsgToAllJSONResponse struct { RequestId int `json:"request_id"` PushMsgToAllResponse PushMsgToAllResponse `json:"response_params"` }
type PushMsgToAllRequest ¶
type PushMsgToAllRequest struct { MsgType int //消息类型 0:消息;1:通知 Message string //消息内容,json格式, http://push.baidu.com/doc/restapi/msg_struct MsgExpires int //相对于当前时间的消息过期时间,单位为秒 默认为5小时(18000秒) DeployStatus int //设置iOS应用的部署状态,仅iOS应用推送时使用 1:开发状态;2:生产状态; 若不指定,则默认设置为生产状态。 SendTime int64 //定时推送,用于指定的实际发送时间 必须在当前时间60s以外,1年以内 }
func (*PushMsgToAllRequest) AddToParams ¶
func (r *PushMsgToAllRequest) AddToParams(params *OrderedParams) *OrderedParams
type PushMsgToAllResponse ¶
type PushMsgToSingleDeviceJSONResponse ¶
type PushMsgToSingleDeviceJSONResponse struct { RequestId int `json:"request_id"` PushMsgToSingleDeviceResponse PushMsgToSingleDeviceResponse `json:"response_params"` }
type PushMsgToSingleDeviceRequest ¶
type PushMsgToSingleDeviceRequest struct { ChannelId string //唯一对应一台设备 MsgType int //消息类型 0:消息;1:通知 Message string //消息内容,json格式, http://push.baidu.com/doc/restapi/msg_struct MsgExpires int64 //相对于当前时间的消息过期时间,单位为秒 默认为5小时(18000秒) DeployStatus int //设置iOS应用的部署状态,仅iOS应用推送时使用 1:开发状态;2:生产状态; 若不指定,则默认设置为生产状态。 }
func (*PushMsgToSingleDeviceRequest) AddToParams ¶
func (r *PushMsgToSingleDeviceRequest) AddToParams(params *OrderedParams) *OrderedParams
type PushMsgToTagJSONResponse ¶
type PushMsgToTagJSONResponse struct { RequestId int `json:"request_id"` PushMsgToTagResponse PushMsgToTagResponse `json:"response_params"` }
type PushMsgToTagRequest ¶
type PushMsgToTagRequest struct { TagName string //标签名 必须是已创建的 MsgType int //消息类型 0:消息;1:通知 Message string //消息内容,json格式, http://push.baidu.com/doc/restapi/msg_struct MsgExpires int //相对于当前时间的消息过期时间,单位为秒 默认为5小时(18000秒) DeployStatus int //设置iOS应用的部署状态,仅iOS应用推送时使用 1:开发状态;2:生产状态; 若不指定,则默认设置为生产状态。 SendTime int64 //定时推送,用于指定的实际发送时间 必须在当前时间60s以外,1年以内 }
func (*PushMsgToTagRequest) AddToParams ¶
func (r *PushMsgToTagRequest) AddToParams(params *OrderedParams) *OrderedParams
type PushMsgToTagResponse ¶
type QueryDeviceNumInTagJSONResponse ¶
type QueryDeviceNumInTagJSONResponse struct { RequestId int `json:"request_id"` QueryDeviceNumInTagResponse QueryDeviceNumInTagResponse `json:"response_params"` }
type QueryDeviceNumInTagRequest ¶
type QueryDeviceNumInTagRequest struct {
TagName string
}
func (*QueryDeviceNumInTagRequest) AddToParams ¶
func (r *QueryDeviceNumInTagRequest) AddToParams(params *OrderedParams) *OrderedParams
type QueryDeviceNumInTagResponse ¶
type QueryDeviceNumInTagResponse struct {
DeviceNum int `json:"device_num"`
}
type QueryMsgStatusJSONResponse ¶
type QueryMsgStatusJSONResponse struct { RequestId int `json:"request_id"` QueryMsgStatusResponse QueryMsgStatusResponse `json:"response_params"` }
type QueryMsgStatusRequest ¶
type QueryMsgStatusRequest struct {
MsgId string
}
func (*QueryMsgStatusRequest) AddToParams ¶
func (r *QueryMsgStatusRequest) AddToParams(params *OrderedParams) *OrderedParams
type QueryMsgStatusResponse ¶
type QueryMsgStatusResponse struct { TotalNum int `json:"total_num"` MsgSendInfos []MsgSendInfo `json:"result"` }
type QueryStatisticDeviceJSONResponse ¶
type QueryStatisticDeviceJSONResponse struct { RequestId int `json:"request_id"` QueryStatisticDeviceResponse QueryStatisticDeviceResponse `json:"response_params"` }
type QueryStatisticDeviceResponse ¶
type QueryStatisticDeviceResponse struct { TotalNum int `json:"total_num"` Result map[string]DeviceStatUnit `json:"result"` }
type QueryStatisticTopicJSONResponse ¶
type QueryStatisticTopicJSONResponse struct { RequestId int `json:"request_id"` QueryStatisticTopicResponse QueryStatisticTopicResponse `json:"response_params"` }
type QueryStatisticTopicRequest ¶
type QueryStatisticTopicRequest struct {
TopicId string
}
func (*QueryStatisticTopicRequest) AddToParams ¶
func (r *QueryStatisticTopicRequest) AddToParams(params *OrderedParams) *OrderedParams
type QueryStatisticTopicResponse ¶
type QueryStatisticTopicResponse struct { TotalNum int `json:"total_num"` Result map[string]TopicStatUnit `json:"result"` }
type QueryTagsJSONResponse ¶
type QueryTagsJSONResponse struct { RequestId int `json:"request_id"` QueryTagsResponse QueryTagsResponse `json:"response_params"` }
type QueryTagsRequest ¶
func (*QueryTagsRequest) AddToParams ¶
func (r *QueryTagsRequest) AddToParams(params *OrderedParams) *OrderedParams
type QueryTagsResponse ¶
type QueryTimerListJSONResponse ¶
type QueryTimerListJSONResponse struct { RequestId int `json:"request_id"` QueryTimerListResponse QueryTimerListResponse `json:"response_params"` }
type QueryTimerListRequest ¶
func (*QueryTimerListRequest) AddToParams ¶
func (r *QueryTimerListRequest) AddToParams(params *OrderedParams) *OrderedParams
type QueryTimerListResponse ¶
type QueryTimerListResponse struct { TotalNum int `json:"total_num"` TimerResultInfos []TimerResultInfo `json:"result"` }
type QueryTimerRecordsJSONResponse ¶
type QueryTimerRecordsJSONResponse struct { RequestId int `json:"request_id"` QueryTimerRecordsResponse QueryTimerRecordsResponse `json:"response_params"` }
type QueryTimerRecordsRequest ¶
type QueryTimerRecordsRequest struct { TimerId string Start int Limit int RangeStart int64 RangeEnd int64 }
func (*QueryTimerRecordsRequest) AddToParams ¶
func (r *QueryTimerRecordsRequest) AddToParams(params *OrderedParams) *OrderedParams
type QueryTopicListJSONResponse ¶
type QueryTopicListJSONResponse struct { RequestId int `json:"request_id"` QueryTopicListResponse QueryTopicListResponse `json:"response_params"` }
type QueryTopicListRequest ¶
func (*QueryTopicListRequest) AddToParams ¶
func (r *QueryTopicListRequest) AddToParams(params *OrderedParams) *OrderedParams
type QueryTopicListResponse ¶
type QueryTopicListResponse struct { TotalNum int `json:"total_num"` TopicResultInfos []TopicResultInfo `json:"topics"` }
type QueryTopicRecordsJSONResponse ¶
type QueryTopicRecordsJSONResponse struct { RequestId int `json:"request_id"` QueryTopicRecordsResponse QueryTopicRecordsResponse `json:"response_params"` }
type QueryTopicRecordsRequest ¶
type QueryTopicRecordsRequest struct { TopicId string Start int Limit int RangeStart int64 RangeEnd int64 }
func (*QueryTopicRecordsRequest) AddToParams ¶
func (r *QueryTopicRecordsRequest) AddToParams(params *OrderedParams) *OrderedParams
type TimerResultInfo ¶
type TimerResultInfo struct {
// contains filtered or unexported fields
}
type TopicResultInfo ¶
type TopicStatUnit ¶
type TopicStatUnit struct {
Ack int `json:"ack"`
}