Пример #1
0
    def _get_headers(self):
        timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
        msg = 'ACCESSKEY' + self.access_key + 'TIMESTAMP' + timestamp
        headers = {'TimeStamp': timestamp,
                   'AccessKey': self.access_key,
                   'Signature': util.get_signature(self.secret_key, msg)}

        return headers
    def _get_headers(self):
        timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
        msg = 'ACCESSKEY' + self.access_key + 'TIMESTAMP' + timestamp
        headers = {'TimeStamp': timestamp,
                   'AccessKey': self.access_key,
                   'Signature': util.get_signature(self.secret_key, msg)}

        return headers
Пример #3
0
    def _get_headers(self):
        access_key = core.get_access_key()
        secret_key = core.get_secret_key()

        timestamp = time.strftime("%Y-%m-%d %H:%M:%S")
        msg = "ACCESSKEY" + access_key + "TIMESTAMP" + timestamp
        headers = {"TimeStamp": timestamp, "AccessKey": access_key, "Signature": util.get_signature(secret_key, msg)}

        return headers
Пример #4
0
#coding=utf-8
#email  [email protected]
#处理微信请求 (xml 格式)


from util import get_signature , XMLTagText2Dict , Dict2XMLTagText
from pprint import pprint

get_signature('dddd' , '5555dddd' , 'kfkfkfk')

def _testXML(xml_str):
    d = XMLTagText2Dict().parse(xml_str)
    pprint(d)
    print (Dict2XMLTagText().toxml(d))

#消息推送
#当普通微信用户向公众账号发消息时,微信服务器将POST该消息到填写的URL上


#1、文本消息
PushMsgxml = '''
 <xml>
 <ToUserName><![CDATA[toUser]]></ToUserName>
 <FromUserName><![CDATA[fromUser]]></FromUserName> 
 <CreateTime>1348831860</CreateTime>
 <MsgType><![CDATA[text]]></MsgType>
 <Content><![CDATA[this is a test]]></Content>
 <MsgId>1234567890123456</MsgId>
 </xml>'''

_testXML( PushMsgxml )