mirror of
https://github.com/xxjwxc/public.git
synced 2025-09-26 20:01:19 +08:00
1
This commit is contained in:
@@ -29,6 +29,7 @@ const (
|
||||
_sendCustom = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token="
|
||||
_sendFreepublish = "https://api.weixin.qq.com/cgi-bin/freepublish/batchget?access_token="
|
||||
_setGuideConfig = "https://api.weixin.qq.com/cgi-bin/guide/setguideconfig?access_token="
|
||||
_setGetMaterial = "https://api.weixin.qq.com/cgi-bin/material/get_material?access_token="
|
||||
_getUser = "https://api.weixin.qq.com/cgi-bin/user/get?access_token="
|
||||
_cacheToken = "wx_access_token"
|
||||
_cacheTicket = "weixin_card_ticket"
|
||||
@@ -335,7 +336,7 @@ func (_wx *wxTools) GetAllOpenId() ([]string, error) {
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// GetFreepublish 获取用户列表
|
||||
// GetFreepublish 获取成功发布列表
|
||||
func (_wx *wxTools) GetFreepublish(max int64) (out []FreepublishiInfo, err error) {
|
||||
accessToken, err := _wx.GetAccessToken()
|
||||
if err != nil {
|
||||
@@ -368,6 +369,7 @@ func (_wx *wxTools) GetFreepublish(max int64) (out []FreepublishiInfo, err error
|
||||
item.Digest = v.Digest
|
||||
item.ContentSourceUrl = v.ContentSourceUrl
|
||||
item.Url = v.Url
|
||||
item.ThumbMediaId = v.ThumbMediaId
|
||||
item.IsDeleted = v.IsDeleted
|
||||
out = append(out, item)
|
||||
}
|
||||
@@ -381,3 +383,27 @@ func (_wx *wxTools) GetFreepublish(max int64) (out []FreepublishiInfo, err error
|
||||
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// GetMaterial 获取素材地址
|
||||
func (_wx *wxTools) GetMaterial(mediaId string) (string, error) {
|
||||
accessToken, err := _wx.GetAccessToken()
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
req := MediaIdReq{
|
||||
MediaId: mediaId,
|
||||
}
|
||||
|
||||
bo, _ := json.Marshal(req)
|
||||
resb, _ := myhttp.OnPostJSON(_setGetMaterial+accessToken, string(bo))
|
||||
var res MediaResp
|
||||
json.Unmarshal(resb, &res)
|
||||
if len(res.DownUrl) > 0 {
|
||||
return res.DownUrl, nil
|
||||
}
|
||||
if len(res.NewsItemS) > 0 {
|
||||
return res.NewsItemS[0].Url, nil
|
||||
}
|
||||
|
||||
return "", nil
|
||||
}
|
||||
|
@@ -190,6 +190,7 @@ type FreepublishiInfo struct { // 公众号文章
|
||||
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"` // 更新时间
|
||||
}
|
||||
@@ -222,5 +223,22 @@ type FreepublishiInfoNewItem struct {
|
||||
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 MediaIdReq struct {
|
||||
MediaId string `json:"media_id"` // 永久素材id
|
||||
}
|
||||
|
||||
type MediaResp struct {
|
||||
Title string `json:"title"` // 素材标题
|
||||
DownUrl string `json:"down_url"` // 素材下载地址
|
||||
NewsItemS []NewsItem `json:"news_item"` //
|
||||
}
|
||||
|
||||
type NewsItem struct {
|
||||
Title string `json:"title"` // 素材标题
|
||||
Url string `json:"url"` // 图文页的URL
|
||||
ContentSourceUrl string `json:"content_source_url"` // 图文消息的原文地址,即点击“阅读原文”后的URL
|
||||
}
|
||||
|
@@ -35,6 +35,7 @@ type WxTools interface {
|
||||
GetWxQrcode(path, page string, width int) (ret QrcodeRet) // 获取小程序二维码 (有限个)
|
||||
GetAllOpenId() ([]string, error) // 获取所有用户id
|
||||
GetFreepublish(max int64) ([]FreepublishiInfo, error) // 获取成功发布列表,最大条数
|
||||
GetMaterial(mediaId string) (string, error) // 获取素材地址
|
||||
// --------------------h5------------------------------
|
||||
GetWebOauth(code string) (*AccessToken, error) // 授权
|
||||
GetWebUserinfo(openid, accessToken string) (*WxUserinfo, error) // 获取用户信息
|
||||
|
Reference in New Issue
Block a user