微信公众号 django 开发库
`wechat-python-sdk`是一个微信sdk库,负责和微信的api通信。
但是在多进程环境中,每个进程都会维护自己的一份`Access Token`(同理`JsApi Ticket`),
并且会导致其他进程的`Access Token`失效,所以我们需要一种持久化的方式,让多个进程统一获取和更新一份`Access Token`。
`django-wechat`通过数据库持久化解决了这个问题,并且支持同时使用多个公众号。
Quick start
-----------
1 添加 "djwechat" 到 INSTALLED_APPS中
```
INSTALLED_APPS = (
...
'djwechat',
)
```
2 运行 `python manage.py migrate`,以创建 django-wechat models.
3 在admin后台,添加对应微信号的账号认证信息 和 JsApiList
1)账号认证信息的值为:
```
{
"WEIXIN_TOKEN": "6G9IH7EF4D83C5AB",
"WEIXIN_APP_ID": "wx67fb1f4877bfd511",
"WEIXIN_APP_SECRET": "646332665dcd63f9e8b83a474f2dbe38",
"WEIXIN_ENCODING_AES_KEY": "ZvhDvkQ8QpRUvNZUQgDRvrU3ICQEBVEdLvEsmsXTscA"
}
```
2)已申请的JsApiList权限,以空格隔开,如下所示:
```
scanQRCode getLocation getNetworkType onMenuShareTimeline onMenuShareAppMessage onMenuShareQQ onMenuShareWeibo chooseWXPay
```
4 在 `django` 中使用
```
from djwechat.util import get_wechat
appid = 'XXXXXXXXXXXXXXXXXX'
wechat = get_wechat(appid)
....
```
djwechat会自动在数据库中保存和更新 access_token、jsapi_ticket, 用户只需负责调用就行。
Metadata
Release files for django-wechat-sdk 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| django-wechat-sdk-0.2.1.tar.gz | 9.6 kB | Without provenance | Details |
Release files / django-wechat-sdk-0.2.1.tar.gz
| Download URL | django-wechat-sdk-0.2.1.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d1e1ad2275bd624d6b820101a9e075eaecb2527e47d614f5e92cfc82210e61b
|
|
BLAKE2b-256 checksum How to use checksums |
04a979c1d7576b136ca9cbf5255e9f905dc9e3af0a5d3a164e687ccc5c5bc445
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for django-wechat-sdk 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.