offia

package
v1.8.101 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2024 License: Zlib Imports: 10 Imported by: 0

Documentation

Overview

*

  • 事件数据结构 *
  • 微信服务器在五秒内收不到响应会断掉连接,并且重新发起请求,总共重试三次。 *
  • 1 关注/取消关注事件
  • 2 扫描带参数二维码事件
  • 3 上报地理位置事件
  • 4 自定义菜单事件
  • 5 点击菜单拉取消息时的事件推送
  • 6 点击菜单跳转链接时的事件推送

Index

Constants

View Source
const (
	EMSubscribe   = "subscribe"
	EMUnsubscribe = "unsubscribe"
	EMScan        = "SCAN"
	EMLocation    = "LOCATION"
	EMClick       = "CLICK"
	EMView        = "VIEW"
)

Variables

This section is empty.

Functions

func ClearQuota

func ClearQuota(api *token.Api) error

ClearQuota 所有api调用(包括第三方帮其调用)次数进行清零,每月10次 https://api.weixin.qq.com/cgi-bin/clear_quota?access_token=ACCESS_TOKEN

func GenerateShortUrl added in v1.8.38

func GenerateShortUrl(api *token.Api, longUrl string) (string, error)

GenerateShortUrl 长链接转短链接接口 https://api.weixin.qq.com/cgi-bin/shorturl?access_token=ACCESS_TOKEN

func GetCallbackIP

func GetCallbackIP(api *token.Api) ([]string, error)

GetCallbackIP 获取微信服务器IP地址 https://api.weixin.qq.com/cgi-bin/getcallbackip?access_token=ACCESS_TOKEN

func GetTicket added in v1.8.38

func GetTicket(tk token.Token, d data.D) (*token.Ticket, error)

func QRGetBitmap added in v1.8.38

func QRGetBitmap(ticket string) ([]byte, error)

QRGetBitmap 获取二维码ticket后,开发者可用ticket换取二维码图片。请注意,本接口无须登录态即可调用。 HTTP GET请求(请使用https协议)https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=TICKET 提醒:TICKET记得进行UrlEncode ticket正确情况下,http 返回码是200,是一张图片,可以直接展示或者下载。

HEAD Accept-Ranges:bytes IsCache-control:max-age=604800 Connection:keep-alive Content-Length:28026 Content-Name:image/jpg

func UserCancelBlack added in v1.8.38

func UserCancelBlack(api *token.Api, req *BatchReq) error

UserCancelBlack 取消拉黑用户 POST https://api.weixin.qq.com/cgi-bin/tags/members/batchunblacklist?access_token=ACCESS_TOKEN

func UserGetUnionId added in v1.8.38

func UserGetUnionId(api *token.Api, openid string) (string, error)

UserGetUnionId 获取 unionid GET https://api.weixin.qq.com/wxa/getpaidunionid?access_token=ACCESS_TOKEN&openid=OPENID

func UserSetBlack added in v1.8.38

func UserSetBlack(api *token.Api, req *BatchReq) error

UserSetBlack 拉黑用户 公众号可通过该接口来拉黑一批用户,黑名单列表由一串 OpenId (加密后的微信号,每个用户对每个公众号的OpenID是唯一的)组成。 POST https://api.weixin.qq.com/cgi-bin/tags/members/batchblacklist?access_token=ACCESS_TOKEN

Types

type ActionInfo added in v1.8.38

type ActionInfo struct {
	Scene Scene `json:"scene"`
}

type AllMsg added in v1.8.38

type AllMsg struct {
	Head
	EvData
	MsgData
}

All pack

func (AllMsg) IsEvent added in v1.8.38

func (m AllMsg) IsEvent() bool

func (AllMsg) ToEvent added in v1.8.38

func (m AllMsg) ToEvent() *EventMsg

func (AllMsg) ToNormal added in v1.8.38

func (m AllMsg) ToNormal() *NormalMsg

type BatchReq added in v1.8.38

type BatchReq struct {
	OpenIdList []string `json:"begin_openid,omitempty"`
}

type BlackReq added in v1.8.38

type BlackReq struct {
	OpenId string `json:"begin_openid,omitempty"`
}

type EvData added in v1.8.38

type EvData struct {
	Event string `xml:"Event,omitempty" json:"Event,omitempty"`

	//for subscribe  unsubscribe, SCAN, LOCATION, CLICK, VIEW
	EventKey string `xml:"EventKey,omitempty"  json:"EventKey,omitempty"`

	//for 扫二维码
	Ticket string `xml:"Ticket,omitempty"  json:"Ticket,omitempty"`

	//上报地理位置事件
	Latitude  float64 `xml:"Latitude" json:"Latitude,omitempty"`   //地理位置纬度
	Longitude float64 `xml:"Longitude" json:"Longitude,omitempty"` //地理位置经度
	Precision float64 `xml:"Precision" json:"Precision,omitempty"` //地理位置精度

	//点击菜单跳转链接时的事件推送 .EventMsg = "VIEW"
	MenuID string `xml:"MenuID" json:"MenuID,omitempty"` //指菜单ID,如果是个性化菜单,则可以通过这个字段,知道是哪个规则的菜单被点击了。

	Status string `xml:"Status" json:"Status,omitempty"`

	//for 客户 user_enter_tempsession
	SessionFrom string `xml:"SessionFrom" json:"SessionFrom,omitempty"`
}

type EventMsg added in v1.8.38

type EventMsg struct {
	Head
	EvData
}

.MsgType = "event"

type Head struct {
	ToAppId    string
	ToUser     string `xml:"ToUserName" json:"ToUserName"`     //开发者微信号
	FromUser   string `xml:"FromUserName" json:"FromUserName"` //OpenId
	CreateTime int64  `xml:"CreateTime" json:"CreateTime"`
	MsgType    string `xml:"MsgType" json:"MsgType"`
}

type Industry added in v1.8.38

type Industry struct {
	FirstClass  string `json:"first_class"`
	SecondClass string `json:"second_class"`
}

所属行业

type IndustryReq added in v1.8.38

type IndustryReq struct {
	Id1 string `json:"industry_id1"`
	Id2 string `json:"industry_id2"`
}

所属行业设置

type IndustryS added in v1.8.38

type IndustryS struct {
	Primary   Industry `json:"primary_industry"`
	Secondary Industry `json:"secondary_industry"`
}
type Link struct {
	Title string
	Desc  string
	Url   string
}

type Location added in v1.8.38

type Location struct {
	LocationX float64 //地理位置纬度
	LocationY float64 //地理位置经度
	Scale     float64 //地理位置精度
	Label     string  //地址
}

type MsgData added in v1.8.38

type MsgData struct {
	MsgId string `xml:"MsgId,omitempty" json:"MsgId,omitempty"`

	// text
	Content string `xml:"Content,omitempty" json:"Content,omitempty"`

	// media
	MediaId string `xml:"MediaId,omitempty" json:"MediaId,omitempty"`

	// image
	PicUrl string `xml:"PicUrl,omitempty" json:"PicUrl,omitempty"`

	// voice
	Format      string `xml:"Format,omitempty" json:"Format,omitempty"`
	Recognition string `xml:"Recognition,omitempty" json:"Recognition,omitempty"`

	// video
	ThumbMediaId string `xml:"ThumbMediaId,omitempty" json:"ThumbMediaId,omitempty"`

	//地理位置
	LocationX float64 `xml:"Location_X,omitempty" json:"Location_X,omitempty"` //地理位置纬度
	LocationY float64 `xml:"Location_Y,omitempty" json:"Location_Y,omitempty"` //地理位置经度
	Scale     float64 `xml:"Scale,omitempty" json:"Scale,omitempty"`           //地理位置精度
	Label     string  `xml:"Label,omitempty" json:"Label,omitempty"`           //地址

	//link
	Title string `xml:"Title" json:"Title,omitempty"`
	Desc  string `xml:"Description" json:"Description,omitempty"`
	Url   string `xml:"Url,omitempty" json:"Url,omitempty"`

	//小卡片
	AppId    string `xml:"AppId" json:"AppId,omitempty"`
	PagePath string `xml:"PagePath" json:"PagePath,omitempty"`
	ThumbUrl string `xml:"ThumbUrl,omitempty" json:"ThumbUrl,omitempty"`
}

type NormalMsg added in v1.8.38

type NormalMsg struct {
	Head
	MsgData
}

.MsgType = text .MsgType = image .MsgType = voice .MsgType = location .MsgType = shortvideo

type OpenId added in v1.8.38

type OpenId struct {
	OpenId []string `json:"openid"`
}

type QRCode added in v1.8.38

type QRCode struct {
	Ticket string `json:"ticket"`
	Expire int64  `json:"expire_seconds"`
	Url    string `json:"url"`
}

func QRCreate added in v1.8.38

func QRCreate(api *token.Api, qr *QRCodeReq) (*QRCode, error)

QRCreate 临时二维码请求说明

http请求方式: POST URL: https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKEN POST数据格式:json POST数据例子:{"expire_seconds": 604800, "action_name": "QR_SCENE", "action_info": {"scene": {"scene_id": 123}}}

或者也可以使用以下POST数据创建字符串形式的二维码参数: {"expire_seconds": 604800, "action_name": "QR_STR_SCENE", "action_info": {"scene": {"scene_str": "test"}}} 2 永久二维码请求说明

http请求方式: POST URL: https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKEN POST数据格式:json POST数据例子:{"action_name": "QR_LIMIT_SCENE", "action_info": {"scene": {"scene_id": 123}}}

或者也可以使用以下POST数据创建字符串形式的二维码参数: {"action_name": "QR_LIMIT_STR_SCENE", "action_info": {"scene": {"scene_str": "test"}}} expire_seconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。 action_name 二维码类型,QR_SCENE为临时的整型参数值,QR_STR_SCENE为临时的字符串参数值,QR_LIMIT_SCENE为永久的整型参数值,QR_LIMIT_STR_SCENE为永久的字符串参数值 action_info 二维码详细信息 scene_id 场景值ID,临时二维码时为32位非0整型,永久二维码时最大值为100000(目前参数只支持1--100000) scene_str 场景值ID(字符串形式的ID),字符串类型,长度限制为1到64

返回 {"ticket":"gQH47joAAAAAAAAAASxodHRwOi8vd2VpeGluLnFxLmNvbS9xL2taZ2Z3TVRtNzJXV1Brb3ZhYmJJAAIEZ23sUwMEmm ticket 获取的二维码ticket,凭借此ticket可以在有效时间内换取二维码。 expire_seconds 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天)。 url 二维码图片解析后的地址,开发者可根据该地址自行生成需要的二维码图片

type QRCodeReq added in v1.8.38

type QRCodeReq struct {
	Expire     int64      `json:"expire_seconds,omitempty"`
	ActionName string     `json:"action_name"`
	ActionInfo ActionInfo `json:"action_info"`
}

二维码

func QRGenerateReq added in v1.8.38

func QRGenerateReq(expireSeconds int64, actionName, sceneStr string, sceneId int32) QRCodeReq

QRGenerateReq

  • 临时二维码 QRGenerateReq(6000,"QR_SCENE","", 1) OR GenReq(6000,"QR_STR_SCENE","test", 0)

  • 永久二维码 QRGenerateReq(0,"QR_LIMIT_SCENE","", 1) OR GenReq(0,"QR_LIMIT_STR_SCENE","test", 0)

type QrcBuffer added in v1.8.38

type QrcBuffer struct {
	Type string `json:"contentType"`
	Buff []byte `json:"buffer"`
}

type Scene added in v1.8.38

type Scene struct {
	SceneId  int32  `json:"scene_id,omitempty"`  //场景值ID,临时二维码时为32位非0整型,永久二维码时最大值为100000(目前参数只支持1--100000)
	SceneStr string `json:"scene_str,omitempty"` //场景值ID(字符串形式的ID),字符串类型,长度限制为1到64
}

type ShortUrlReq added in v1.8.38

type ShortUrlReq struct {
	Action string `json:"action"` //=long2short
	Url    string `json:"long_url"`
}

长链接转短链接

type TMInfo added in v1.8.38

type TMInfo struct {
	Id              string `json:"template_id"`
	Title           string `json:"title"`
	PrimaryIndustry string `json:"primary_industry"`
	DeputyIndustry  string `json:"deputy_industry"`
	Content         string `json:"content"`
	Example         string `json:"example"`
}

模板信息

type Ticket added in v1.8.38

type Ticket struct {
	Ticket   string `json:"ticket"`
	ExpireIn int64  `json:"expires_in"`
}

func JSApiGetTicket added in v1.8.38

func JSApiGetTicket(api *token.Api) (*Ticket, error)

type UserOpenIdList added in v1.8.38

type UserOpenIdList struct {
	Total      int32  `json:"total"`
	Count      int32  `json:"count"`
	Data       OpenId `json:"data"`
	NextOpenId string `json:"next_openid"`
}

func UserGetBlack added in v1.8.38

func UserGetBlack(api *token.Api, nextopenid string) (*UserOpenIdList, error)

UserGetBlack 获取公众号的黑名单列表

公众号可通过该接口来获取帐号的黑名单列表,黑名单列表由一串 OpenId(加密后的微信号,每个用户对每个公众号的OpenID是唯一的)组成。

该接口每次调用最多可拉取 10000 个OpenID,当列表数较多时,可以通过多次拉取的方式来满足需求。 POST https://api.weixin.qq.com/cgi-bin/tags/members/getblacklist?access_token=ACCESS_TOKEN

func UserGetList added in v1.8.38

func UserGetList(api *token.Api, nextopenid string) (*UserOpenIdList, error)

UserGetList 获取用户列表 公众号可通过本接口来获取帐号的关注者列表,关注者列表由一串OpenID(加密后的微信号,每个用户对每个公众号的OpenID是唯一的)组成。一次拉取调用最多拉取10000个关注者的OpenID,可以通过多次拉取的方式来满足需求。 GET https://api.weixin.qq.com/cgi-bin/user/get?access_token=ACCESS_TOKEN&next_openid=NEXT_OPENID

type Video added in v1.8.38

type Video struct {
	MediaId      string
	ThumbMediaId string
}

type Voice added in v1.8.38

type Voice struct {
	MediaId string
	Format  string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL