github.com/chanxuehong/wechat@v0.0.0-20230222024006-36f0325263cd/mp/shakearound/page/add.go (about) 1 package page 2 3 import ( 4 "github.com/chanxuehong/wechat/mp/core" 5 ) 6 7 type AddParameters struct { 8 Title string `json:"title"` // 必须, 在摇一摇页面展示的主标题,不超过6个字 9 Description string `json:"description"` // 必须, 在摇一摇页面展示的副标题,不超过7个字 10 PageURL string `json:"page_url"` // 必须, 跳转链接 11 IconURL string `json:"icon_url"` // 必须, 在摇一摇页面展示的图片。图片需先上传至微信侧服务器,用“素材管理-上传图片素材”接口上传图片,返回的图片URL再配置在此处 12 Comment string `json:"comment,omitempty"` // 可选, 页面的备注信息,不超过15个字 13 } 14 15 // 新增页面 16 func Add(clt *core.Client, para *AddParameters) (pageId int64, err error) { 17 var result struct { 18 core.Error 19 Data struct { 20 PageId int64 `json:"page_id"` 21 } `json:"data"` 22 } 23 24 incompleteURL := "https://api.weixin.qq.com/shakearound/page/add?access_token=" 25 if err = clt.PostJSON(incompleteURL, para, &result); err != nil { 26 return 27 } 28 29 if result.ErrCode != core.ErrCodeOK { 30 err = &result.Error 31 return 32 } 33 pageId = result.Data.PageId 34 return 35 }