当前位置: 首页 > news >正文

网络运维前景seo优化技术

网络运维前景,seo优化技术,国内可以上的网站,宁波住房和城乡建设委员会官方网站背景:我有一个《砂舞指南》的小程序,主要是分享砂舞最新动态等 最近做了一个小程序,想要一些固定的文章展示在小程序里面,比如《什么是砂舞》《玩砂舞注意点》等普及砂舞知识的文章 开发流程: 1、刚开始测试了 素材…

背景:我有一个《砂舞指南》的小程序,主要是分享砂舞最新动态等

最近做了一个小程序,想要一些固定的文章展示在小程序里面,比如《什么是砂舞》《玩砂舞注意点》等普及砂舞知识的文章

开发流程:

1、刚开始测试了 素材管理/获取永久素材,但是结果不甚满意。发表了20篇文章,只获取到15个。不知道是平台规则的修改还是什么的,无法满足需求

2、翻了半天,找个 发布能力/获取成功发布列表。
刚开始获取不到发表的文章列表,查了查,得知, 发布/发表 是俩个文章

发布:就是在发表按钮点击后,不群发文章。在微信公众号首页能看到文章,但是不给粉丝推送
发表:勾选推送,群发给粉丝

所以,发布能力/获取成功发布列表,这个接口刚好满足我的需求

实现:

我的服务器是用golang来处理的

package wechatFreePublishimport ("bytes""fmt""github.com/goccy/go-json""net/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", i+1)//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", j+1)//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:"title"`Author             string `json:"author"`Digest             string `json:"digest"`Content            string `json:"content"`ContentSourceURL   string `json:"content_source_url"`ThumbMediaID       string `json:"thumb_media_id"`ShowCoverPic       int    `json:"show_cover_pic"`NeedOpenComment    int    `json:"need_open_comment"`OnlyFansCanComment int    `json:"only_fans_can_comment"`URL                string `json:"url"`IsDeleted          bool   `json:"is_deleted"`
}type NewsMediaItem struct {ArticleID string `json:"article_id"`Content   struct {NewsItem []NewsItem `json:"news_item"`} `json:"content"`UpdateTime int `json:"update_time"`
}type NewsMediaResponse struct {TotalCount int             `json:"total_count"`ItemCount  int             `json:"item_count"`Items      []NewsMediaItem `json:"item"`
}

获取成功发布列表后,又衍生出个问题,我想要获取文章是缩略图。但是数据只提供了个缩略图id,并没有直接的URL地址

因微信公众号的接口每天有次数限制,那么我只能调用 素材管理/获取永久素材/image,将素材库的所有图片存储到我的服务器,然后在获取文章的时候,在缓存中用图片ID获取图片URL,返回给客户端了。

这样,微信小程序就有了  文章标题+缩略图URL,就可以展示自己需要的文章了

后续,只要在公众号发布文章,即可同步到小程序。

http://www.tj-hxxt.cn/news/73.html

相关文章:

  • 网站建设基础知识及专业术语游戏搬砖工作室加盟平台
  • 行业门户网站建设方案书榆林seo
  • 南京企业网站制作价格360优化大师安卓手机版下载安装
  • wap是什么意思啊优化大师win7
  • 湖北省建设厅乡镇污水官方网站营销推广方式都有哪些
  • 沣东新城开发建设集团有限公司网站下载百度导航最新版本
  • 百度站长平台网站改版工具免费发链接的网站
  • 高端品牌服装福州seo博客
  • 成都企业网站建设费用百度有效点击软件
  • 深圳婚纱摄影网站建设公司调查公司
  • 即墨网站建设哪里有神马搜索seo优化排名
  • 专门做代购的网站武汉网站竞价推广
  • 3340网站建设与管理门户网站软文
  • 财务管理咨询太原seo推广外包
  • 策划案需要给做网站吗吉林关键词排名优化软件
  • 桐城做淘宝店铺网站公司百度推广登录后台
  • 网站开发技术 难点深圳网络营销运营
  • 织梦模板添加网站地图免费自助建站平台
  • 专业网站建设webmeng培训班报名
  • 深圳做营销网站公司全面网络推广营销策划
  • 成都企业网站维护成品网站源码
  • 网站诊断表近三天新闻50字左右
  • 可以做兼职的网站免费发布广告信息的网站
  • 加强网站硬件建设方案网站内容优化方法
  • 四川宜宾网站建设企业邮箱怎么注册
  • 网站信息批量查询工具百度有免费推广广告
  • 公司注册资本多少有什么关系seo优化资源
  • 很好的网站建设互联网营销案例分析
  • 软件工具有哪些seo网络推广招聘
  • 传奇私服列表网站怎么做大兵seo博客