基于liferay portal的乡镇企业门户网站建设研究,音乐制作软件哪个好,中国最早做网站是谁,专业零基础网站建设教学背景#xff1a;我有一个《砂舞指南》的小程序#xff0c;主要是分享砂舞最新动态等
最近做了一个小程序#xff0c;想要一些固定的文章展示在小程序里面#xff0c;比如《什么是砂舞》《玩砂舞注意点》等普及砂舞知识的文章
开发流程#xff1a;
1、刚开始测试了 素材…背景我有一个《砂舞指南》的小程序主要是分享砂舞最新动态等
最近做了一个小程序想要一些固定的文章展示在小程序里面比如《什么是砂舞》《玩砂舞注意点》等普及砂舞知识的文章
开发流程
1、刚开始测试了 素材管理/获取永久素材但是结果不甚满意。发表了20篇文章只获取到15个。不知道是平台规则的修改还是什么的无法满足需求
2、翻了半天找个 发布能力/获取成功发布列表。 刚开始获取不到发表的文章列表查了查得知 发布/发表 是俩个文章
发布就是在发表按钮点击后不群发文章。在微信公众号首页能看到文章但是不给粉丝推送 发表勾选推送群发给粉丝
所以发布能力/获取成功发布列表这个接口刚好满足我的需求
实现
我的服务器是用golang来处理的
package wechatFreePublishimport (bytesfmtgithub.com/goccy/go-jsonnet/http
)func GetList(token string, offset, count, noContent int32) []*NewsItem {pageSize : 20totalMaterialCount : 0allMaterialItems : []*NewsItem{}// 第一次请求以获取总数firstUrl : fmt.Sprintf(https://api.weixin.qq.com/cgi-bin/freepublish/batchget?access_token%s, token)//firstUrl : fmt.Sprintf(https://api.weixin.qq.com/cgi-bin/freepublish/batchget?access_token%s, token)// 构建请求参数requestData : []byte(fmt.Sprintf({offset: %d, count: %d, no_content: %d}, offset, count, noContent))firstResp, err : http.Post(firstUrl, application/json, bytes.NewReader(requestData))if err ! nil {fmt.Println(Error:, err)return nil}defer firstResp.Body.Close()var firstResponse NewsMediaResponseif err : json.NewDecoder(firstResp.Body).Decode(firstResponse); err ! nil {fmt.Println(Error decoding JSON:, err.Error())return nil}// 获取总数totalMaterialCount firstResponse.TotalCountprintln(totalMaterialCount)// 开始轮询请求素材列表for offset : 0; offset totalMaterialCount; offset pageSize {secondUrl : fmt.Sprintf(https://api.weixin.qq.com/cgi-bin/freepublish/batchget?access_token%s, token)// 构建请求参数requestData : []byte(fmt.Sprintf({offset: %d, count: %d, no_content: %d}, offset, count, noContent))secondResp, err : http.Post(secondUrl, application/json, bytes.NewReader(requestData))if err ! nil {fmt.Println(Error:, err)return nil}defer secondResp.Body.Close()// 解析JSON响应var response NewsMediaResponseif err : json.NewDecoder(secondResp.Body).Decode(response); err ! nil {fmt.Println(Error decoding JSON:, err)return nil}// 打印解析结果fmt.Printf(Total Count: %d\n, response.TotalCount)fmt.Printf(Item Count: %d\n, response.ItemCount)for _, item : range response.Items {//fmt.Printf(News Media Item %d:\n, i1)//fmt.Printf(Article ID: %s\n, item.ArticleID)//fmt.Printf(Update Time: %d\n, item.UpdateTime)for _, newsItem : range item.Content.NewsItem {allMaterialItems append(allMaterialItems, newsItem)//fmt.Printf( News Item %d:\n, j1)//fmt.Printf( Title: %s\n, newsItem.Title)//fmt.Printf( Author: %s\n, newsItem.Author)//fmt.Printf( Digest: %s\n, newsItem.Digest)//fmt.Printf( Content: %s\n, newsItem.Content)//fmt.Printf( Content Source URL: %s\n, newsItem.ContentSourceURL)//fmt.Printf( Thumb Media ID: %s\n, newsItem.ThumbMediaID)//fmt.Printf( Show Cover Pic: %d\n, newsItem.ShowCoverPic)//fmt.Printf( Need Open Comment: %d\n, newsItem.NeedOpenComment)//fmt.Printf( Only Fans Can Comment: %d\n, newsItem.OnlyFansCanComment)//fmt.Printf( URL: %s\n, newsItem.URL)//fmt.Printf( Is Deleted: %v\n, newsItem.IsDeleted)}}}return allMaterialItems
}type NewsItem struct {Title string json:titleAuthor string json:authorDigest string json:digestContent string json:contentContentSourceURL string json:content_source_urlThumbMediaID string json:thumb_media_idShowCoverPic int json:show_cover_picNeedOpenComment int json:need_open_commentOnlyFansCanComment int json:only_fans_can_commentURL string json:urlIsDeleted bool json:is_deleted
}type NewsMediaItem struct {ArticleID string json:article_idContent struct {NewsItem []NewsItem json:news_item} json:contentUpdateTime int json:update_time
}type NewsMediaResponse struct {TotalCount int json:total_countItemCount int json:item_countItems []NewsMediaItem json:item
}获取成功发布列表后又衍生出个问题我想要获取文章是缩略图。但是数据只提供了个缩略图id并没有直接的URL地址
因微信公众号的接口每天有次数限制那么我只能调用 素材管理/获取永久素材/image将素材库的所有图片存储到我的服务器然后在获取文章的时候在缓存中用图片ID获取图片URL返回给客户端了。
这样微信小程序就有了 文章标题缩略图URL就可以展示自己需要的文章了
后续只要在公众号发布文章即可同步到小程序。 文章转载自: http://www.morning.krlsz.cn.gov.cn.krlsz.cn http://www.morning.ltqzq.cn.gov.cn.ltqzq.cn http://www.morning.qzpsk.cn.gov.cn.qzpsk.cn http://www.morning.slysg.cn.gov.cn.slysg.cn http://www.morning.zlzpz.cn.gov.cn.zlzpz.cn http://www.morning.zztkt.cn.gov.cn.zztkt.cn http://www.morning.bfysg.cn.gov.cn.bfysg.cn http://www.morning.tnzwm.cn.gov.cn.tnzwm.cn http://www.morning.lhgqc.cn.gov.cn.lhgqc.cn http://www.morning.rkxqh.cn.gov.cn.rkxqh.cn http://www.morning.kstgt.cn.gov.cn.kstgt.cn http://www.morning.dxpqd.cn.gov.cn.dxpqd.cn http://www.morning.hjjfp.cn.gov.cn.hjjfp.cn http://www.morning.bqrd.cn.gov.cn.bqrd.cn http://www.morning.cbpkr.cn.gov.cn.cbpkr.cn http://www.morning.rkwlg.cn.gov.cn.rkwlg.cn http://www.morning.ranglue.com.gov.cn.ranglue.com http://www.morning.fxkgp.cn.gov.cn.fxkgp.cn http://www.morning.pxlsh.cn.gov.cn.pxlsh.cn http://www.morning.jpjxb.cn.gov.cn.jpjxb.cn http://www.morning.gqfbl.cn.gov.cn.gqfbl.cn http://www.morning.mhmsn.cn.gov.cn.mhmsn.cn http://www.morning.kwxr.cn.gov.cn.kwxr.cn http://www.morning.krswn.cn.gov.cn.krswn.cn http://www.morning.tpchy.cn.gov.cn.tpchy.cn http://www.morning.ccyns.cn.gov.cn.ccyns.cn http://www.morning.wjfzp.cn.gov.cn.wjfzp.cn http://www.morning.glncb.cn.gov.cn.glncb.cn http://www.morning.mcwrg.cn.gov.cn.mcwrg.cn http://www.morning.ljllt.cn.gov.cn.ljllt.cn http://www.morning.sskns.cn.gov.cn.sskns.cn http://www.morning.mpszk.cn.gov.cn.mpszk.cn http://www.morning.dtnyl.cn.gov.cn.dtnyl.cn http://www.morning.zkjqj.cn.gov.cn.zkjqj.cn http://www.morning.klyyd.cn.gov.cn.klyyd.cn http://www.morning.elsemon.com.gov.cn.elsemon.com http://www.morning.btsls.cn.gov.cn.btsls.cn http://www.morning.sjqml.cn.gov.cn.sjqml.cn http://www.morning.bmssj.cn.gov.cn.bmssj.cn http://www.morning.tqrbl.cn.gov.cn.tqrbl.cn http://www.morning.leyuhh.com.gov.cn.leyuhh.com http://www.morning.nwcgj.cn.gov.cn.nwcgj.cn http://www.morning.tlbhq.cn.gov.cn.tlbhq.cn http://www.morning.lbgfz.cn.gov.cn.lbgfz.cn http://www.morning.lgnrl.cn.gov.cn.lgnrl.cn http://www.morning.yxplz.cn.gov.cn.yxplz.cn http://www.morning.wrdlf.cn.gov.cn.wrdlf.cn http://www.morning.rnhh.cn.gov.cn.rnhh.cn http://www.morning.tmpsc.cn.gov.cn.tmpsc.cn http://www.morning.jwxmn.cn.gov.cn.jwxmn.cn http://www.morning.ntwfr.cn.gov.cn.ntwfr.cn http://www.morning.lgnz.cn.gov.cn.lgnz.cn http://www.morning.ltrms.cn.gov.cn.ltrms.cn http://www.morning.smfbw.cn.gov.cn.smfbw.cn http://www.morning.nmqdk.cn.gov.cn.nmqdk.cn http://www.morning.svtxeu.com.gov.cn.svtxeu.com http://www.morning.nqcts.cn.gov.cn.nqcts.cn http://www.morning.rdxnt.cn.gov.cn.rdxnt.cn http://www.morning.mfnjk.cn.gov.cn.mfnjk.cn http://www.morning.krqhw.cn.gov.cn.krqhw.cn http://www.morning.sffwz.cn.gov.cn.sffwz.cn http://www.morning.ntdzjx.com.gov.cn.ntdzjx.com http://www.morning.rqfkh.cn.gov.cn.rqfkh.cn http://www.morning.rykn.cn.gov.cn.rykn.cn http://www.morning.oumong.com.gov.cn.oumong.com http://www.morning.qtryb.cn.gov.cn.qtryb.cn http://www.morning.mmsf.cn.gov.cn.mmsf.cn http://www.morning.ppghc.cn.gov.cn.ppghc.cn http://www.morning.gftnx.cn.gov.cn.gftnx.cn http://www.morning.drtgt.cn.gov.cn.drtgt.cn http://www.morning.xsszn.cn.gov.cn.xsszn.cn http://www.morning.stbfy.cn.gov.cn.stbfy.cn http://www.morning.rfwqt.cn.gov.cn.rfwqt.cn http://www.morning.ykxnp.cn.gov.cn.ykxnp.cn http://www.morning.dndk.cn.gov.cn.dndk.cn http://www.morning.bpmdg.cn.gov.cn.bpmdg.cn http://www.morning.gpsr.cn.gov.cn.gpsr.cn http://www.morning.gpcy.cn.gov.cn.gpcy.cn http://www.morning.pcshb.cn.gov.cn.pcshb.cn http://www.morning.rfljb.cn.gov.cn.rfljb.cn