Skip to main content

Wechat Ticket Module for Python.

Project description

Wechat Ticket Module for Python.

Installation

pip install pywe-ticket

Usage

MemoryStorage:

Ticket::

    # Sandbox: http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login
    In [1]: from pywe_ticket import Ticket

    In [2]: ticket = Ticket('wx7aad305aed68bfe3', '9eac636765940ec286055c559ff84039')

    In [3]: ticket.
    ticket.API_DOMAIN       ticket.WECHAT_TICKET    ticket.expires_at       ticket.refresh_ticket   ticket.ticket           ticket.type
    ticket.MCH_DOMAIN       ticket.api_ticket       ticket.get              ticket.secret           ticket.ticket_info_key
    ticket.OPEN_DOMAIN      ticket.appid            ticket.jsapi_ticket     ticket.storage          ticket.tickets

    In [3]: ticket.ticket()
    Out[3]: u'sM4AOVdWfPE4DxkXGEs8VB_Ml7aLXlo2_KgFGduwNU6irBzC2ySEv3Ofex5q2eY1C50R-GffnrsRWFI7uDim9g'

    In [4]: ticket.jsapi_ticket()
    Out[4]: u'sM4AOVdWfPE4DxkXGEs8VB_Ml7aLXlo2_KgFGduwNU6irBzC2ySEv3Ofex5q2eY1C50R-GffnrsRWFI7uDim9g'

    In [5]: ticket.api_ticket()
    Out[5]: u'E0o2-at6NcC2OsJiQTlwlEaNeSfCJatHbnTsr44R0i4GASKTn-ZELWB3Oe7cpRbg5bLf4ZD5Ylg5cuOqma8LxA'


ticket::

    In [1]: from pywe_ticket import ticket, api_ticket, jsapi_ticket

    In [2]: ticket('wx7aad305aed68bfe3', '9eac636765940ec286055c559ff84039')
    Out[2]: u'sM4AOVdWfPE4DxkXGEs8VB_Ml7aLXlo2_KgFGduwNU6irBzC2ySEv3Ofex5q2eY1C50R-GffnrsRWFI7uDim9g'

    In [3]: api_ticket('wx7aad305aed68bfe3', '9eac636765940ec286055c559ff84039')
    Out[3]: u'E0o2-at6NcC2OsJiQTlwlEaNeSfCJatHbnTsr44R0i4GASKTn-ZELWB3Oe7cpRbg5bLf4ZD5Ylg5cuOqma8LxA'

    In [4]: jsapi_ticket('wx7aad305aed68bfe3', '9eac636765940ec286055c559ff84039')
    Out[4]: u'sM4AOVdWfPE4DxkXGEs8VB_Ml7aLXlo2_KgFGduwNU6irBzC2ySEv3Ofex5q2eY1C50R-GffnrsRWFI7uDim9g'

RedisStorage:

Ticket::

    In [1]: import redis_extensions as redis

    In [2]: r = redis.StrictRedisExtensions(host='localhost', port=6379, db=0)

    In [3]: from pywe_storage import RedisStorage

    In [4]: storage = RedisStorage(r)

    In [5]: from pywe_ticket import Ticket

    In [6]: ticket = Ticket('wx7aad305aed68bfe3', '9eac636765940ec286055c559ff84039', storage=storage)

    In [7]: ticket.ticket()
    Out[7]: u'sM4AOVdWfPE4DxkXGEs8VB_Ml7aLXlo2_KgFGduwNU6-KN0maRl2mp5Gn8-ah5WDDphfA-zyZ4AfBb3Q13O8LA'

    In [8]: r.get('pywe:wx7aad305aed68bfe3:jsapi:ticket:info')
    Out[8]: '{"ticket": "sM4AOVdWfPE4DxkXGEs8VB_Ml7aLXlo2_KgFGduwNU6-KN0maRl2mp5Gn8-ah5WDDphfA-zyZ4AfBb3Q13O8LA", "expires_at": 1499767753, "expires_in": 7200, "errcode": 0, "errmsg": "ok"}'


ticket::

    In [1]: import redis_extensions as redis

    In [2]: r = redis.StrictRedisExtensions(host='localhost', port=6379, db=0)

    In [3]: from pywe_storage import RedisStorage

    In [4]: storage = RedisStorage(r)

    In [5]: from pywe_ticket import ticket

    In [6]: ticket('wx7aad305aed68bfe3', '9eac636765940ec286055c559ff84039', storage=storage)
    Out[6]: u'sM4AOVdWfPE4DxkXGEs8VB_Ml7aLXlo2_KgFGduwNU6-KN0maRl2mp5Gn8-ah5WDDphfA-zyZ4AfBb3Q13O8LA'

    In [7]: r.get('pywe:wx7aad305aed68bfe3:jsapi:ticket:info')
    Out[7]: '{"ticket": "sM4AOVdWfPE4DxkXGEs8VB_Ml7aLXlo2_KgFGduwNU6-KN0maRl2mp5Gn8-ah5WDDphfA-zyZ4AfBb3Q13O8LA", "expires_at": 1499767753, "expires_in": 7200, "errcode": 0, "errmsg": "ok"}'

Method

class Ticket(BaseWechat):
    def __init__(self, appid=None, secret=None, type='jsapi', storage=None, token_fetched_func=None):

def ticket(self, appid=None, secret=None, token=None, type='jsapi', storage=None, token_fetched_func=None):

def api_ticket(self, appid=None, secret=None, token=None, storage=None, token_fetched_func=None):

def jsapi_ticket(self, appid=None, secret=None, token=None, storage=None, token_fetched_func=None):

def refresh_ticket(self, appid=None, secret=None, token=None, type='jsapi', storage=None, token_fetched_func=None):

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pywe-ticket-1.1.1.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

pywe_ticket-1.1.1-py2.py3-none-any.whl (4.1 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file pywe-ticket-1.1.1.tar.gz.

File metadata

File hashes

Hashes for pywe-ticket-1.1.1.tar.gz
Algorithm Hash digest
SHA256 febebcb33121a3f918c2f2f35c29943caae0ebc92749397fe06eb129bf22e529
MD5 9384ab9c75a61da84e7289f16a108cf7
BLAKE2b-256 f7c3d59e3f255818284f53b1dc3ddadc62ea9c097602f0d709b9038ae3182388

See more details on using hashes here.

File details

Details for the file pywe_ticket-1.1.1-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pywe_ticket-1.1.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 8466a5dfe16d7e14b6f45b5f428ca66a3fe323c74cc820b977080c2836d7e2ab
MD5 74ac444bb80d6da66e292066de0e60b7
BLAKE2b-256 a8004e8bd09de8cb5e4f40c809bbc1061458f05537fa81474796d968fcd6c5c2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page