Skip to content

Commit

Permalink
Update some documentations
Browse files Browse the repository at this point in the history
  • Loading branch information
messense committed Mar 4, 2016
1 parent 353b75e commit cee8d5d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
3 changes: 3 additions & 0 deletions docs/client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ WeChatClient
# client.media.xxx()
# client.group.xxx()

如果不提供 ``session`` 参数,默认使用 ``wechatpy.session.memorystorage.MemoryStorage`` session 类型,
注意该类型不是线程安全的,不推荐生产环境使用。

.. module:: wechatpy.client.api

WeChatUser 用户 API
Expand Down
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ wechatpy 是一个微信 (WeChat) 公众平台的第三方 Python SDK, 实现了
pay

微信企业号平台接口
-------------------
---------------------

TODO: 待完善

微信公众号第三方平台接口
----------------------
-----------------------------

.. toctree::
:maxdepth: 2
Expand Down
40 changes: 40 additions & 0 deletions wechatpy/client/api/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ def get(self, user_id, lang='zh_CN'):
:param user_id: 用户 ID 。 就是你收到的 `Message` 的 source
:param lang: 返回国家地区语言版本,zh_CN 简体,zh_TW 繁体,en 英语
:return: 返回的 JSON 数据包
使用示例::
from wechatpy import WeChatClient
client = WeChatClient('appid', 'secret')
user = client.user.get('openid')
"""
assert lang in ('zh_CN', 'zh_TW', 'en'), 'lang can only be one of \
zh_CN, zh_TW, en language codes'
Expand All @@ -34,6 +42,14 @@ def get_followers(self, first_user_id=None):
:param first_user_id: 可选。第一个拉取的 OPENID,不填默认从头开始拉取
:return: 返回的 JSON 数据包
使用示例::
from wechatpy import WeChatClient
client = WeChatClient('appid', 'secret')
followers = client.user.get_followers()
"""
params = {}
if first_user_id:
Expand All @@ -52,6 +68,14 @@ def update_remark(self, user_id, remark):
:param user_id: 用户 ID 。 就是你收到的 `Message` 的 source
:param remark: 备注名
:return: 返回的 JSON 数据包
使用示例::
from wechatpy import WeChatClient
client = WeChatClient('appid', 'secret')
client.user.update_remark('openid', 'Remark')
"""
return self._post(
'user/info/updateremark',
Expand All @@ -70,6 +94,14 @@ def get_group_id(self, user_id):
:param user_id: 用户 ID
:return: 用户所在分组 ID
使用示例::
from wechatpy import WeChatClient
client = WeChatClient('appid', 'secret')
group_id = client.user.get_group_id('openid')
"""
res = self._post(
'groups/getid',
Expand All @@ -87,6 +119,14 @@ def get_batch(self, user_list):
:param user_id: user_list
:return: 用户信息的 list
使用示例::
from wechatpy import WeChatClient
client = WeChatClient('appid', 'secret')
users = client.user.get_batch(['openid1', 'openid2'])
"""
res = self._post(
'user/info/batchget',
Expand Down
1 change: 1 addition & 0 deletions wechatpy/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
def register_event(event_type):
"""
Register the event class so that they can be accessed from EVENT_TYPES
:param event_type: Event type
"""
def register(cls):
Expand Down
7 changes: 4 additions & 3 deletions wechatpy/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@

def parse_message(xml):
"""
Parse WeChat XML format messages
:param xml: XML format messages
:return: Parsed messages or events
解析微信服务器推送的 XML 消息
:param xml: XML 消息
:return: 解析成功返回对应的消息或事件,否则返回 ``UnknownMessage``
"""
if not xml:
return
Expand Down

0 comments on commit cee8d5d

Please sign in to comment.