| @@ 11-35 (lines=25) @@ | ||
| 8 | ||
| 9 | class WeChatMaterial(BaseWeChatAPI): |
|
| 10 | ||
| 11 | def add_articles(self, articles): |
|
| 12 | """ |
|
| 13 | 新增永久图文素材 |
|
| 14 | 详情请参考 |
|
| 15 | https://qydev.weixin.qq.com/wiki/index.php?title=%E4%B8%8A%E4%BC%A0%E6%B0%B8%E4%B9%85%E7%B4%A0%E6%9D%90 |
|
| 16 | ||
| 17 | :param articles: 图文素材数组 |
|
| 18 | :return: 返回的 JSON 数据包 |
|
| 19 | """ |
|
| 20 | articles_data = [] |
|
| 21 | for article in articles: |
|
| 22 | articles_data.append({ |
|
| 23 | 'thumb_media_id': article['thumb_media_id'], |
|
| 24 | 'title': article['title'], |
|
| 25 | 'content': article['content'], |
|
| 26 | 'author': article.get('author', ''), |
|
| 27 | 'content_source_url': article.get('content_source_url', ''), |
|
| 28 | 'digest': article.get('digest', ''), |
|
| 29 | 'show_cover_pic': article.get('show_cover_pic', 0) |
|
| 30 | }) |
|
| 31 | return self._post( |
|
| 32 | 'material/add_mpnews', |
|
| 33 | data={ |
|
| 34 | "mpnews": { |
|
| 35 | "articles": articles_data |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ) |
|
| @@ 69-92 (lines=24) @@ | ||
| 66 | } |
|
| 67 | ) |
|
| 68 | ||
| 69 | def upload_articles(self, articles): |
|
| 70 | """ |
|
| 71 | 上传图文消息素材 |
|
| 72 | 详情请参考 |
|
| 73 | http://mp.weixin.qq.com/wiki/15/5380a4e6f02f2ffdc7981a8ed7a40753.html |
|
| 74 | ||
| 75 | :param articles: 图文消息数组 |
|
| 76 | :return: 返回的 JSON 数据包 |
|
| 77 | """ |
|
| 78 | articles_data = [] |
|
| 79 | for article in articles: |
|
| 80 | articles_data.append({ |
|
| 81 | 'thumb_media_id': article['thumb_media_id'], |
|
| 82 | 'title': article['title'], |
|
| 83 | 'content': article['content'], |
|
| 84 | 'author': article.get('author', ''), |
|
| 85 | 'content_source_url': article.get('content_source_url', ''), |
|
| 86 | 'digest': article.get('digest', ''), |
|
| 87 | 'show_cover_pic': article.get('show_cover_pic', 0) |
|
| 88 | }) |
|
| 89 | return self._post( |
|
| 90 | 'media/uploadnews', |
|
| 91 | data={ |
|
| 92 | 'articles': articles_data |
|
| 93 | } |
|
| 94 | ) |
|
| 95 | ||