Documentation
¶
Index ¶
- Constants
- Variables
- func NewWeLM(config *WeLMInfoReq, authorization string) *weLM
- type APITicket
- type AccessToken
- type ActionInfo
- type ActionScene
- type Choices
- type CustomImage
- type CustomMsg
- type CustomMusic
- type CustomText
- type CustomVoice
- type FreepublishiInfo
- type FreepublishiInfoContent
- type FreepublishiInfoItem
- type FreepublishiInfoNewItem
- type FreepublishiInfoReq
- type FreepublishiInfoResp
- type GetblacklistReq
- type GetblacklistResp
- type GuideAutoReply
- type GuideConfig
- type GuideFastReplyList
- type H5QrcodeReq
- type H5QrcodeResp
- type MediaIdReq
- type MediaResp
- type NewsItem
- type OpenIDData
- type QrcodeRet
- type ResTempMsg
- type SubButton
- type TempMsg
- type TempWebMsg
- type UploadTmpFileResp
- type UserInfo
- type WeLMInfoReq
- type WeLMInfoResp
- type WxGetUser
- type WxGetUserData
- type WxInfo
- type WxJsSign
- type WxMenu
- type WxMenuButton
- type WxPhoneResp
- type WxPhoneinfo
- type WxTools
- type WxUserinfo
Constants ¶
View Source
const ( PAY_SUCCESS = 1 //支付成功 PAY_REFUND = 2 //转入退款 PAY_CLOSED = 3 //已关闭 PAY_NOTPAY = 4 //未支付 PAY_REVOKED = 5 //已撤销 PAY_USERPAYING = 6 //支付中 PAY_ERROR = -1 //支付失败 )
View Source
const ( GETSHAREURL = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" //小程序码 GETQRCODEURL = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" //小程序二维码 GETH5QRCODEURL = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" //h5二维码 )
Variables ¶
View Source
var CertFileLoc = "/conf/cert/apiclient_cert.pem"
CertFileLoc cert.pem
View Source
var KeyFileLoc = "/conf/cert/apiclient_key.pem"
KeyFileLoc key.pem
View Source
var RootcaFileLoc = "/conf/cert/rootca.pem"
RootcaFileLoc rootca.pem
Functions ¶
func NewWeLM ¶
func NewWeLM(config *WeLMInfoReq, authorization string) *weLM
Types ¶
type APITicket ¶
type APITicket struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
Ticket string `json:"ticket"`
ExpiresIn int `json:"expires_in"`
}
APITicket ...
type AccessToken ¶
type AccessToken struct {
AccessToken string `json:"access_token"` // 网页授权接口调用凭证,注意:此access_token与基础支持的access_token不同
ExpiresIn int `json:"expires_in"` // access_token接口调用凭证超时时间,单位(秒)
RefreshToken string `json:"refresh_token"` // 用户刷新access_token
Openid string `json:"openid"` // 用户唯一标识,请注意,在未关注公众号时,用户访问公众号的网页,也会产生一个用户和公众号唯一的OpenID
Scope string `json:"scope"` // 用户授权的作用域,使用逗号(,)分隔
}
type ActionInfo ¶
type ActionInfo struct {
Scene ActionScene `json:"scene"`
}
type ActionScene ¶
type ActionScene struct {
SceneStr string `json:"scene_str"` // 场景值ID(字符串形式的ID),字符串类型,长度限制为1到64
}
type CustomImage ¶
type CustomImage struct {
MediaId string `json:"media_id"` // 图片
}
type CustomMsg ¶
type CustomMsg struct {
Touser string `json:"touser"` // 是 接收者(用户)的 openid
Msgtype string `json:"msgtype"` // 是 所需下发的模板消息的id
Text *CustomText `json:"text,omitempty"` // 文本类容
Voice *CustomVoice `json:"voice,omitempty"` // 语音
Music *CustomMusic `json:"music,omitempty"` // 音乐消息
Image *CustomImage `json:"image,omitempty"` // 图片消息
}
CustomMsg 客服消息头
type CustomMusic ¶
type CustomText ¶
type CustomText struct {
Content string `json:"content"` // 文本类容
}
type CustomVoice ¶
type CustomVoice struct {
MediaId string `json:"media_id"` // 语音
}
type FreepublishiInfo ¶
type FreepublishiInfo struct {
ArticleId string `json:"article_id"` // 成功发布的图文消息id
Title string `json:"title"` // 文章标题
Author string `json:"author"` // 作者
Digest string `json:"digest"` // 摘要
ContentSourceUrl string `json:"content_source_url"` // 图文消息的原文地址,即点击“阅读原文”后的URL
Url string `json:"url"` // 图文消息的URL
ThumbMediaId string `json:"thumb_media_id"` // 图文消息的封面图片素材id(一定是永久MediaID)
IsDeleted bool `json:"is_deleted"` // 该图文是否被删除
UpdateTime int64 `json:"update_time"` // 更新时间
}
type FreepublishiInfoContent ¶
type FreepublishiInfoContent struct {
NewsItem []FreepublishiInfoNewItem `json:"news_item"` // 成功发布的图文消息id
}
type FreepublishiInfoItem ¶
type FreepublishiInfoItem struct {
ArticleId string `json:"article_id"` // 成功发布的图文消息id
UpdateTime int64 `json:"update_time"` // 更新时间
Content FreepublishiInfoContent `json:"content"`
}
type FreepublishiInfoNewItem ¶
type FreepublishiInfoNewItem struct {
Title string `json:"title"` // 文章标题
Author string `json:"author"` // 作者
Digest string `json:"digest"` // 再要
ContentSourceUrl string `json:"content_source_url"` // 图文消息的原文地址,即点击“阅读原文”后的URL
Url string `json:"url"` // 图文消息的URL
ThumbMediaId string `json:"thumb_media_id"` // 图文消息的封面图片素材id(一定是永久MediaID)
IsDeleted bool `json:"is_deleted"` // 该图文是否被删除
}
type FreepublishiInfoReq ¶
type FreepublishiInfoResp ¶
type FreepublishiInfoResp struct {
TotalCount int `json:"total_count"`
ItemCount int `json:"item_count"`
Item []FreepublishiInfoItem `json:"item"`
}
type GetblacklistReq ¶
type GetblacklistReq struct {
BeginOpenid string `json:"begin_openid"` // 开始的openid
}
type GetblacklistResp ¶
type GetblacklistResp struct {
Total int64 `json:"total"` // 总量
Count int64 `json:"count"` // 素材下载地址
Data OpenIDData `json:"data"` //
NextOpenid string `json:"next_openid"`
}
type GuideAutoReply ¶
type GuideConfig ¶
type GuideConfig struct {
GuideAccount string `json:"guide_account"` // 顾问号
IsDelete bool `json:"is_delete"` // 操作类型,false表示添加 true表示删除
GuideFastReplyList []GuideFastReplyList `json:"guide_fast_reply_list"` // 快捷回复列表
GuideAutoReply GuideAutoReply `json:"guide_auto_reply"` // 第一条新客户关注自动回复
GuideAutoReplyPlus GuideAutoReply `json:"guide_auto_reply_plus"` // 第二条新客户关注自动回复
}
type GuideFastReplyList ¶
type GuideFastReplyList struct {
Content string `json:"content"` // 快捷回复
}
GuideFastReplyList 快捷回复列表
type H5QrcodeReq ¶
type H5QrcodeReq struct {
ExpireSeconds int `json:"expire_seconds"` // 该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为60秒。
ActionName string `json:"action_name"` // 二维码类型,QR_SCENE为临时的整型参数值,QR_STR_SCENE为临时的字符串参数值,QR_LIMIT_SCENE为永久的整型参数值,QR_LIMIT_STR_SCENE为永久的字符串参数值
SceneId int `json:"scene_id"` // 场景值ID,临时二维码时为32位非0整型,永久二维码时最大值为100000(目前参数只支持1--100000
ActionInfo ActionInfo `json:"action_info"` // 二维码详细信息
}
type H5QrcodeResp ¶
type MediaIdReq ¶
type MediaIdReq struct {
MediaId string `json:"media_id"` // 永久素材id
}
type OpenIDData ¶
type OpenIDData struct {
Openid []string `json:"openid"`
}
type ResTempMsg ¶
ResTempMsg 模版消息返回值
type TempMsg ¶
type TempMsg struct {
Touser string `json:"touser"` // 是 接收者(用户)的 openid
TemplateID string `json:"template_id"` // 是 所需下发的模板消息的id
Page string `json:"page"` // 否 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
Data map[string]map[string]string `json:"data"` //是 模板内容,不填则下发空模板
}
TempMsg 订阅消息头
type TempWebMsg ¶
type TempWebMsg struct {
Touser string `json:"touser"` // 是 接收者(用户)的 openid
TemplateID string `json:"template_id"` // 是 所需下发的模板消息的id
Page string `json:"url"` // 否 点击模板卡片后的跳转页面,仅限本小程序内的页面。支持带参数,(示例index?foo=bar)。该字段不填则模板无跳转。
Data map[string]map[string]string `json:"data"` //是 模板内容,不填则下发空模板
}
TempMsg 订阅消息头
type UploadTmpFileResp ¶
type UserInfo ¶
type UserInfo struct {
OpenID string `json:"openid"`
Nickname string `json:"nickname"`
Sex int32 `json:"sex"`
Province string `json:"province"`
City string `json:"city"`
Country string `json:"country"`
HeadImgURL string `json:"headimgurl"`
Privilege []string `json:"privilege"`
Unionid string `json:"unionid"`
}
UserInfo 用户信息
type WeLMInfoReq ¶
type WeLMInfoReq struct {
Prompt string `json:"prompt"` // 可选,默认值空字符串,给模型的提示
Model string `json:"model"` // 必选,要使用的模型名称,当前支持的模型名称有medium、 large 和 xl
MaxTokens int `json:"max_tokens"` // 可选,最多生成的token个数,默认值 16
Temperature float64 `json:"temperature"` // 可选 默认值 0.85,表示使用的sampling temperature,更高的temperature意味着模型具备更多的可能性。对于更有创造性的应用,可以尝试0.85以上,而对于有明确答案的应用,可以尝试0(argmax采样)。 建议改变这个值或top_p,但不要同时改变。
TopP float64 `json:"top_p"` // 可选 默认值 0.95,来源于nucleus sampling,采用的是累计概率的方式。即从累计概率超过某一个阈值p的词汇中进行采样,所以0.1意味着只考虑由前10%累计概率组成的词汇。 建议改变这个值或temperature,但不要同时改变。
TopK float64 `json:"top_k"` // 可选 默认值50,从概率分布中依据概率最大选择k个单词,建议不要过小导致模型能选择的词汇少。
N int `json:"n"` // 可选 默认值 1 返回的序列的个数
Echo bool `json:"echo"` // 可选 默认值false,是否返回prompt
Stop string `json:"stop"` // 可选 默认值 null,停止符号。当模型当前生成的字符为stop中的任何一个字符时,会停止生成。若没有配置stop,当模型当前生成的token id 为end_id或生成的token个数达到max_tokens时,停止生成。合理配置stop可以加快推理速度、减少quota消耗。
}
func GetDefaultWelm ¶
func GetDefaultWelm() WeLMInfoReq
type WeLMInfoResp ¶
type WxGetUser ¶
type WxGetUser struct {
Total int64 `json:"total"`
Count int64 `json:"count"`
Data WxGetUserData `json:"data"`
}
type WxGetUserData ¶
type WxInfo ¶
type WxInfo struct {
AppID string // 微信公众平台应用ID
AppSecret string // 微信支付商户平台商户号
APIKey string // 微信支付商户平台API密钥
MchID string // 商户号
NotifyURL string // 通知地址
ShearURL string // 微信分享url
}
WxInfo 微信配置信息
type WxJsSign ¶
type WxJsSign struct {
Appid string `json:"appid"`
Noncestr string `json:"noncestr"`
Timestamp string `json:"timestamp"`
Url string `json:"url"`
Signature string `json:"signature"`
JsapiTicket string `json:"jsapi_ticket"`
}
WxJsSign
type WxMenu ¶
type WxMenu struct {
Button []WxMenuButton `json:"button"`
}
type WxMenuButton ¶
type WxPhoneResp ¶
type WxPhoneResp struct {
Errcode int `json:"errcode"`
Errmsg string `json:"errmsg"`
WxPhoneinfo WxPhoneinfo `json:"phone_info"`
}
WxUserinfo 微信用户信息
type WxPhoneinfo ¶
type WxPhoneinfo struct {
PhoneNumber string `json:"phoneNumber"`
PurePhoneNumber string `json:"purePhoneNumber"`
CountryCode int `json:"countryCode"`
}
WxUserinfo 微信用户信息
type WxTools ¶
type WxTools interface {
SetCache(cache mycache.CacheIFS) // 设置缓存
GetAccessToken() (accessToken string, err error) // 获取登录凭证
GetAPITicket() (ticket string, err error) // 获取微信卡券ticket
GetJsTicket() (ticket string, err error) // 获取微信js ticket
SendTemplateMsg(msg TempMsg) bool // 发送订阅消息
SmallAppOauth(jscode string) string // 小程序授权
SmallAppUnifiedorder(openID string, price int64, priceBody, orderID, clientIP string) message.MessageBody // 小程序统一下单接口
SelectOrder(openID, orderID string) (int, message.MessageBody) // 统一查询接口
RefundPay(openID, orderID, refundNO string, totalFee, refundFee int64) (bool, message.MessageBody) // 申请退款
WxEnterprisePay(openID, tradeNO, desc, ipAddr string, amount int) bool // 企业付款
GetWxQrcode(path, page string, width int) (ret QrcodeRet) // 获取小程序二维码 (有限个)
GetAllOpenId() ([]string, error) // 获取所有用户id
GetFreepublish(max int64) ([]FreepublishiInfo, error) // 获取成功发布列表,最大条数
GetMaterial(mediaId string) (string, error) // 获取素材地址
GetBlacklist(openid string) ([]string, string, error) // 获取黑名单列表
Getuserphonenumber(code string) (string, error) // 手机号获取凭证
// --------------------h5------------------------------
GetWebOauth(code string) (*AccessToken, error) // 授权
GetWebUserinfo(openid, snaccessToken string) (*WxUserinfo, error) // 获取用户信息
SendWebTemplateMsg(msg TempWebMsg) error // 发送公众号模板消息
CreateMenu(menu WxMenu) error // 创建自定义菜单
DeleteMenu() error // 删除自定义菜单
SetGuideConfig(guideConfig GuideConfig) error // 快捷回复与关注自动回复
GetH5Qrcode(expireSeconds int, actionName string, aceneId int) (string, error) // h5获取临时二维码
SendCustomMsg(msg CustomMsg) error // 发送客服消息
UploadTmpFile(path, tp string) (string, error) //上传临时文件(tp:媒体文件类型,分别有图片(image)、语音(voice)、视频(video)和缩略图(thumb))
GetJsSign(url string) (*WxJsSign, error) // js-sdk 授权
}
WxTools 微信操作类型
type WxUserinfo ¶
type WxUserinfo struct {
Openid string `json:"openid"` // 微信用户唯一标识符,,微信用户唯一标识符
NickName string `json:"nickname"` // 用户昵称
Sex int `json:"sex"` // 用户的性别
City string `json:"city"` // 用户所在城市
Province string `json:"province"` // 用户所在省份
Country string `json:"country"` // 用户所在国家
Headimgurl string `json:"headimgurl"` // 头像地址
Unionid string `json:"unionid"` // 用户全局唯一标识
}
WxUserinfo 微信用户信息
Click to show internal directories.
Click to hide internal directories.