示例#1
0
 def send_response(self, data=None, err_code=0, err_msg=''):
     if not data:
         data = {}
     data['return_code'] = 'SUCCESS' if err_code == 0 else 'FAIL'
     data['return_msg'] = err_msg
     self.write(dtools.dict2xml(data))
     self.finish()
示例#2
0
def encrypt_data(data, crypter, appid):
    encrypted = {'encrypt': crypter.encrypt(dtools.dict2xml(data), appid)}
    add_sign_wechat(encrypted, key='wechat_platform')
    return dtools.transfer(
        encrypted,
        renames=[
            ('encrypt', 'Encrypt'),
            ('sign', 'MsgSignature'),
            ('timestamp', 'TimeStamp'),
            ('nonce', 'Nonce')])
示例#3
0
 def send_response(self, data=None, err_code=0, err_msg=''):
     if data:
         self.write(dtools.dict2xml(data))
     self.finish()
示例#4
0
 def write_error(self, status_code, **kwargs):
     data = {'return_code': 'FAIL', 'return_msg': str(status_code)}
     self.write(dtools.dict2xml(data))