mirror of
https://github.com/silenceper/wechat.git
synced 2026-02-12 16:52:28 +08:00
@@ -1,9 +1,10 @@
|
|||||||
language: go
|
language: go
|
||||||
|
|
||||||
go:
|
go:
|
||||||
|
- 1.7
|
||||||
- 1.6
|
- 1.6
|
||||||
- 1.5.3
|
- 1.5
|
||||||
- 1.4.3
|
- 1.4
|
||||||
|
|
||||||
services:
|
services:
|
||||||
- memcached
|
- memcached
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
const (
|
const (
|
||||||
addNewsURL = "https://api.weixin.qq.com/cgi-bin/material/add_news"
|
addNewsURL = "https://api.weixin.qq.com/cgi-bin/material/add_news"
|
||||||
addMaterialURL = "https://api.weixin.qq.com/cgi-bin/material/add_material"
|
addMaterialURL = "https://api.weixin.qq.com/cgi-bin/material/add_material"
|
||||||
|
delMaterialURL = "https://api.weixin.qq.com/cgi-bin/material/del_material"
|
||||||
)
|
)
|
||||||
|
|
||||||
//Material 素材管理
|
//Material 素材管理
|
||||||
@@ -28,6 +29,7 @@ func NewMaterial(context *context.Context) *Material {
|
|||||||
|
|
||||||
//Article 永久图文素材
|
//Article 永久图文素材
|
||||||
type Article struct {
|
type Article struct {
|
||||||
|
Title string `json:"title"`
|
||||||
ThumbMediaID string `json:"thumb_media_id"`
|
ThumbMediaID string `json:"thumb_media_id"`
|
||||||
Author string `json:"author"`
|
Author string `json:"author"`
|
||||||
Digest string `json:"digest"`
|
Digest string `json:"digest"`
|
||||||
@@ -165,3 +167,30 @@ func (material *Material) AddVideo(filename, title, introduction string) (mediaI
|
|||||||
url = resMaterial.URL
|
url = resMaterial.URL
|
||||||
return
|
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
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user