MCPcopy Create free account
hub / github.com/doraemonext/wechat-python-sdk / response_news

Method response_news

wechat_sdk/basic.py:283–305  ·  view source on GitHub ↗

将新闻信息组装为符合微信服务器要求的响应数据 :param articles: list 对象, 每个元素为一个 dict 对象, key 包含 `title`, `description`, `picurl`, `url` :return: 符合微信服务器要求的 XML 响应数据

(self, articles)

Source from the content-addressed store, hash-verified

281 return self._encrypt_response(response)
282
283 def response_news(self, articles):
284 """
285 将新闻信息组装为符合微信服务器要求的响应数据
286 :param articles: list 对象, 每个元素为一个 dict 对象, key 包含 `title`, `description`, `picurl`, `url`
287 :return: 符合微信服务器要求的 XML 响应数据
288 """
289 self._check_parse()
290 for article in articles:
291 if article.get('title'):
292 article['title'] = self._transcoding(article['title'])
293 if article.get('description'):
294 article['description'] = self._transcoding(article['description'])
295 if article.get('picurl'):
296 article['picurl'] = self._transcoding(article['picurl'])
297 if article.get('url'):
298 article['url'] = self._transcoding(article['url'])
299
300 news = ArticleReply(message=self.__message)
301 for article in articles:
302 article = Article(**article)
303 news.add_article(article)
304 response = news.render()
305 return self._encrypt_response(response)
306
307 def group_transfer_message(self):
308 """

Callers 2

test_response_newsMethod · 0.95

Calls 8

_check_parseMethod · 0.95
add_articleMethod · 0.95
renderMethod · 0.95
_encrypt_responseMethod · 0.95
ArticleReplyClass · 0.85
ArticleClass · 0.85
_transcodingMethod · 0.80
getMethod · 0.45

Tested by 1

test_response_newsMethod · 0.76