How to use the wechatpy.WeChatClient function in wechatpy

To help you get started, we’ve selected a few wechatpy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github jxtech / wechatpy / tests / test_session.py View on Github external
def test_memory_session_storage_init(self):
        from wechatpy.session.memorystorage import MemoryStorage

        client = WeChatClient(self.app_id, self.secret)
        self.assertTrue(isinstance(client.session, MemoryStorage))
github jxtech / wechatpy / tests / test_session.py View on Github external
def test_shove_storage_init(self):
        from wechatpy.session.shovestorage import ShoveStorage

        uri = 'memory://'
        client = WeChatClient(self.app_id, self.secret, session=uri)
        self.assertTrue(isinstance(client.session, ShoveStorage))
        self.assertEqual('wechatpy', client.session.prefix)
github jxtech / wechatpy / tests / test_session.py View on Github external
def test_shove_storage_access_token(self):
        uri = 'memory://'
        client = WeChatClient(self.app_id, self.secret, session=uri)
        with HTTMock(wechat_api_mock):
            token = client.fetch_access_token()
            self.assertEqual('1234567890', token['access_token'])
            self.assertEqual(7200, token['expires_in'])
            self.assertEqual('1234567890', client.access_token)
github mn3711698 / Small / manage / mapi / VI_BASE.py View on Github external
def get_wecthpy(self):

        # sql = "select appid,secret from mall where usr_id=%s"
        # l, t = self.db.select(sql, self.subusr_id)
        # appid, secret = l[0]
        # if t == 0:
        #     return 0
        mall=self.oMALL.get(self.subusr_id)
        if mall=={}:
            return 0

        appid=mall['appid']
        secret =mall['secret']
        client = WeChatClient(appid, secret)
        wxa = WeChatWxa(client)
        return wxa
github mn3711698 / Small / api / VI_BASE.py View on Github external
def get_wecthpy(self):

        # sql = "select appid,secret from mall where usr_id=%s"
        # l, t = self.db.select(sql, self.subusr_id)
        # appid, secret = l[0]
        # if t == 0:
        #     return 0
        mall=self.oMALL.get(self.subusr_id)
        if mall=={}:
            return 0

        appid=mall['appid']
        secret =mall['secret']
        client = WeChatClient(appid, secret)
        wxa = WeChatWxa(client)
        return wxa
github jxtech / wechatpy / examples / wxjs / main / views.py View on Github external
def jsapi_signature(request):
    noncestr = '123456'
    timestamp = int(time.time())
    url = request.POST['url']

    client = WeChatClient(settings.WECHAT_APPID, settings.WECHAT_SECRET)
    ticket_response = client.jsapi.get_ticket()
    signature = client.jsapi.get_jsapi_signature(
        noncestr,
        ticket_response['ticket'],
        timestamp,
        url
    )
    ret_dict = {
        'noncestr': noncestr,
        'timestamp': timestamp,
        'url': url,
        'signature': signature,
    }
    return JsonResponse(ret_dict)
github mn3711698 / Small / admin / dl / MODEL_DL.py View on Github external
def get_wecthpy(self):#微信小程序调用
        mall=self.oMALL.get(self.usr_id_p)

        if mall=={}:
            return 0

        appid=mall['appid']
        secret =mall['secret']
        client = WeChatClient(appid, secret)
        wxa = WeChatWxa(client)
        return wxa
github cloverstd / flask-wechatpy / flask_wechatpy / __init__.py View on Github external
host=config.get('WECHAT_SESSION_REDIS_HOST', 'localhost'),
                    port=config.get('WECHAT_SESSION_REDIS_PORT', 6379),
                    db=config.get('WECHAT_SESSION_REDIS_DB', 0),
                    password=config.get('WECHAT_SESSION_REDIS_PASS', None)
                )
            session_interface = RedisStorage(redis, prefix=config['WECHAT_SESSION_PREFIX'])
        elif config['WECHAT_SESSION_TYPE'] == 'memcached':
            from wechatpy.session.memcachedstorage import MemcachedStorage
            mc = self._get_mc_client(config['WECHAT_SESSION_MEMCACHED'])
            session_interface = MemcachedStorage(mc, prefix=config['WECHAT_SESSION_PREFIX'])
        elif config['WECHAT_SESSION_TYPE'] == 'shove':
            pass
        else:
            session_interface = None

        self._wechat_client = WeChatClient(
            config['WECHAT_APPID'],
            config['WECHAT_SECRET'],
            session=session_interface,
            timeout=config['WECHAT_TIMEOUT'],
            auto_retry=config['WECHAT_AUTO_RETRY'],
        )

        if not hasattr(app, 'extensions'):
            app.extensions = {}
        app.extensions['wechatpy'] = self
github mn3711698 / Small / sell / VI_BASE.py View on Github external
def get_wecthpy(self):

        # sql = "select appid,secret from mall where usr_id=%s"
        # l, t = self.db.select(sql, self.subusr_id)
        # appid, secret = l[0]
        # if t == 0:
        #     return 0
        mall=self.oMALL.get(self.usr_id_p)
        if mall=={}:
            return 0

        appid=mall['appid']
        secret =mall['secret']
        client = WeChatClient(appid, secret)
        wxa = WeChatWxa(client)
        return wxa