From 1b7c29f21d8c25ce19efa9ff4a4eb2862f03d889 Mon Sep 17 00:00:00 2001 From: wenzl Date: Sat, 24 Sep 2016 22:28:44 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=B0=B8=E4=B9=85=E7=B4=A0=E6=9D=90=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- material/material.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/material/material.go b/material/material.go index d72f363..a9c512e 100644 --- a/material/material.go +++ b/material/material.go @@ -12,6 +12,7 @@ import ( const ( addNewsURL = "https://api.weixin.qq.com/cgi-bin/material/add_news" addMaterialURL = "https://api.weixin.qq.com/cgi-bin/material/add_material" + delMaterialURL = "https://api.weixin.qq.com/cgi-bin/material/del_material" ) //Material 素材管理 @@ -28,6 +29,7 @@ func NewMaterial(context *context.Context) *Material { //Article 永久图文素材 type Article struct { + Title string `json:"title"` ThumbMediaID string `json:"thumb_media_id"` Author string `json:"author"` Digest string `json:"digest"` @@ -165,3 +167,30 @@ func (material *Material) AddVideo(filename, title, introduction string) (mediaI url = resMaterial.URL return } + +type reqDeleteMaterial struct { + MediaID string `json:"media_id"` +} + +//DeleteMaterial 删除永久素材 +func (material *Material) DeleteMaterial(mediaID string) error { + accessToken, err := material.GetAccessToken() + if err != nil { + return err + } + + uri := fmt.Sprintf("%s?access_token=%s", delMaterialURL, accessToken) + response, err := util.PostJSON(uri, reqDeleteMaterial{mediaID}) + if err != nil { + return err + } + var resDeleteMaterial util.CommonError + err = json.Unmarshal(response, &resDeleteMaterial) + if err != nil { + return err + } + if resDeleteMaterial.ErrCode != 0 { + return fmt.Errorf("DeleteMaterial error : errcode=%v , errmsg=%v", resDeleteMaterial.ErrCode, resDeleteMaterial.ErrMsg) + } + return nil +} From 7375590992c5f9398e245b5a79a33589e2b06d72 Mon Sep 17 00:00:00 2001 From: wenzl Date: Sat, 24 Sep 2016 22:30:23 +0800 Subject: [PATCH 2/2] update .travis.yml --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 595ea0e..d89123f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,9 +1,10 @@ language: go go: + - 1.7 - 1.6 - - 1.5.3 - - 1.4.3 + - 1.5 + - 1.4 services: - memcached