MCPcopy
hub / github.com/wechatpy/wechatpy / send_articles

Method send_articles

wechatpy/client/api/message.py:182–218  ·  view source on GitHub ↗

发送图文消息 详情请参考 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source :param articles: 一个包含至多10个图文的数组, 或者微信图文消息素材 media_id :param account: 可选,客服账号 :return: 返回的 JSON 数据包

(self, user_id, articles, account=None)

Source from the content-addressed store, hash-verified

180 return self._send_custom_message(data, account=account)
181
182 def send_articles(self, user_id, articles, account=None):
183 """
184 发送图文消息
185
186 详情请参考
187 http://mp.weixin.qq.com/wiki/7/12a5a320ae96fecdf0e15cb06123de9f.html
188
189 :param user_id: 用户 ID 。 就是你收到的 `Message` 的 source
190 :param articles: 一个包含至多10个图文的数组, 或者微信图文消息素材 media_id
191 :param account: 可选,客服账号
192 :return: 返回的 JSON 数据包
193 """
194 if isinstance(articles, (tuple, list)):
195 articles_data = []
196 for article in articles:
197 articles_data.append({
198 'title': article['title'],
199 'description': article['description'],
200 'url': article['url'],
201 'picurl': article.get('image', article.get('picurl')),
202 })
203 data = {
204 'touser': user_id,
205 'msgtype': 'news',
206 'news': {
207 'articles': articles_data
208 }
209 }
210 else:
211 data = {
212 'touser': user_id,
213 'msgtype': 'mpnews',
214 'mpnews': {
215 'media_id': articles,
216 }
217 }
218 return self._send_custom_message(data, account=account)
219
220 def send_link(self, user_id, article, account=None):
221 """

Callers 1

Calls 2

_send_custom_messageMethod · 0.95
getMethod · 0.45

Tested by 1