iclientpy.rest.cmd.wxreceiver package

Submodules

iclientpy.rest.cmd.wxreceiver.WXBizMsgCrypt module

对公众平台发送给公众账号的消息加解密示例代码. @copyright: Copyright (c) 1998-2014 Tencent Inc.

exception iclientpy.rest.cmd.wxreceiver.WXBizMsgCrypt.FormatException[源代码]

基类:Exception

class iclientpy.rest.cmd.wxreceiver.WXBizMsgCrypt.PKCS7Encoder[源代码]

基类:object

提供基于PKCS7算法的加解密接口

block_size = 32
decode(decrypted)[源代码]

删除解密后明文的补位字符 @param decrypted: 解密后的明文 @return: 删除补位字符后的明文

encode(text_bytes)[源代码]

对需要加密的明文进行填充补位 @param text_bytes: 需要进行填充补位操作的明文(bytes) @return: 补齐明文字符(bytes)

class iclientpy.rest.cmd.wxreceiver.WXBizMsgCrypt.Prpcrypt(key)[源代码]

基类:object

提供接收和推送给公众平台消息的加解密接口

decrypt(text, appid)[源代码]

对解密后的明文进行补位删除 @param text: 密文 @return: 删除填充补位后的明文

encrypt(text, appid)[源代码]

对明文进行加密 @param text: 需要加密的明文 @return: 加密得到的字符串

get_random_str()[源代码]

随机生成16位字符串 @return: 16位字符串

class iclientpy.rest.cmd.wxreceiver.WXBizMsgCrypt.SHA1[源代码]

基类:object

计算公众平台的消息签名接口

getSHA1(token, timestamp, nonce, encrypt)[源代码]

用SHA1算法生成安全签名 @param token: 票据 @param timestamp: 时间戳 @param encrypt: 密文 @param nonce: 随机字符串 @return: 安全签名

class iclientpy.rest.cmd.wxreceiver.WXBizMsgCrypt.WXBizMsgCrypt(sToken, sEncodingAESKey, sAppId)[源代码]

基类:object

DecryptMsg(sPostData, sMsgSignature, sTimeStamp, sNonce)[源代码]
EncryptMsg(sReplyMsg, sNonce, timestamp=None)[源代码]
VerifyURL(sMsgSignature, sTimeStamp, sNonce, sEchoStr)[源代码]
class iclientpy.rest.cmd.wxreceiver.WXBizMsgCrypt.XMLParse[源代码]

基类:object

提供提取消息格式中的密文及生成回复消息格式的接口

AES_TEXT_RESPONSE_TEMPLATE = '<xml>\n<Encrypt><![CDATA[%(msg_encrypt)s]]></Encrypt>\n<MsgSignature><![CDATA[%(msg_signaturet)s]]></MsgSignature>\n<TimeStamp>%(timestamp)s</TimeStamp>\n<Nonce><![CDATA[%(nonce)s]]></Nonce>\n</xml>'
extract(xmltext)[源代码]

提取出xml数据包中的加密消息 @param xmltext: 待提取的xml字符串 @return: 提取出的加密消息字符串

generate(encrypt, signature, timestamp, nonce)[源代码]

生成xml消息 @param encrypt: 加密后的消息密文 @param signature: 安全签名 @param timestamp: 时间戳 @param nonce: 随机字符串 @return: 生成的xml字符串

iclientpy.rest.cmd.wxreceiver.WXBizMsgCrypt.logger = <Logger iclientpy.rest.cmd.wxreceiver.WXBizMsgCrypt (NOTSET)>

关于Crypto.Cipher模块,ImportError -- No module named 'Crypto'解决方案 请到官方网站 https://www.dlitz.net/software/pycrypto/ 下载pycrypto。 下载后,按照README中的“Installation”小节的提示进行pycrypto安装。

iclientpy.rest.cmd.wxreceiver.WXBizMsgCrypt.throw_exception(message, exception_class=<class 'iclientpy.rest.cmd.wxreceiver.WXBizMsgCrypt.FormatException'>)[源代码]

my define raise exception function

iclientpy.rest.cmd.wxreceiver.WXBizMsgCrypt.to_utf8_bytes(str)[源代码]
iclientpy.rest.cmd.wxreceiver.WXBizMsgCrypt.utf8_bytes_to_str(bytes)[源代码]

iclientpy.rest.cmd.wxreceiver.ierror module

iclientpy.rest.cmd.wxreceiver.server module

class iclientpy.rest.cmd.wxreceiver.server.WXHookReceiver(request, client_address, server)[源代码]

基类:http.server.BaseHTTPRequestHandler

call_msg_fun(*args, **kwargs)[源代码]
do_GET()[源代码]
do_POST()[源代码]
get_msg_fun() → Callable[[str, str], str][源代码]
get_sCorpID() → str[源代码]
get_wxcrypt() → iclientpy.rest.cmd.wxreceiver.WXBizMsgCrypt.WXBizMsgCrypt[源代码]
send(msg: str, status=<HTTPStatus.OK: 200>)[源代码]
send_wx_msg(msg: str, to_user_name, sReqNonce)[源代码]
iclientpy.rest.cmd.wxreceiver.server.start_server(msg_fun: Callable[[str, str], str], sToken: str, sEncodingAESKey: str, sCorpID: str, port: int, bind_ip: str = '0.0.0.0', server_kls=<class 'http.server.HTTPServer'>)[源代码]

Module contents