-
-
Notifications
You must be signed in to change notification settings - Fork 798
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
75 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"errcode":0, | ||
"errmsg":"ok", | ||
"ticket":"bxLdikRXVbTPdHSM05e5u5sUoXNKd8-41ZO3MhKoyN5OfkWITDGgnr2fwJ0m9E8NYzWKVZvdVtaUgWvsdshFKA", | ||
"expires_in":7200 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
wechatpy.client.js | ||
~~~~~~~~~~~~~~~~~~~~ | ||
This module provides some APIs for JS SDK | ||
:copyright: (c) 2014 by messense. | ||
:license: MIT, see LICENSE for more details. | ||
""" | ||
from __future__ import absolute_import, unicode_literals | ||
|
||
from wechatpy.utils import WeChatSigner | ||
from .base import BaseWeChatAPI | ||
|
||
|
||
class WeChatJSAPI(BaseWeChatAPI): | ||
|
||
def get_ticket(self, type='jsapi'): | ||
""" | ||
获取微信 JS-SDK ticket | ||
:return: 返回的 JSON 数据包 | ||
""" | ||
return self._get( | ||
'ticket/getticket', | ||
params={'type': type} | ||
) | ||
|
||
def get_jsapi_signature(self, noncestr, ticket, timestamp, url): | ||
data = [ | ||
'noncestr={noncestr}'.format(noncestr=noncestr), | ||
'jsapi_ticket={ticket}'.format(ticket=ticket), | ||
'timestamp={timestamp}'.format(timestamp=timestamp), | ||
'url={url}'.format(url=url), | ||
] | ||
signer = WeChatSigner(delimiter=b'&') | ||
signer.add_data(*data) | ||
return signer.signature |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters