Weixin for Flask.
Project description
Flask-Weixin is the implementation for http://mp.weixin.qq.com/ with the flavor of Flask. It can be used without Flask too.
Installation
You can install Flask-Weixin with pip:
$ pip install Flask-Weixin
Or, with setuptools easy_install in case you didn’t have pip:
$ easy_install Flask-Weixin
Getting Started
Eager to get started? It is always the Flask way to create a new instance:
from flask_weixin import Weixin weixin = Weixin(app)
Or pass the app later:
weixin = Weixin() weixin.init_app(app)
However, you need to configure before using it, here is the configuration list:
WEIXIN_TOKEN: this is required
WEIXIN_SENDER: a default sender, optional
WEIXIN_EXPIRES_IN: not expires by default
For Flask user, it is suggested that you use the default view function:
app.add_url_rule('/', view_func=weixin.view_func) @weixin.register('*') def reply(**kwargs): username = kwargs.get('sender') sender = kwargs.get('receiver') content = kwargs.get('content') return weixin.reply( username, sender=sender, content=content )
The example above will reply anything the user sent.
Message Types
Every message from weixin has these information:
id: message ID
receiver: which is ToUserName in the official documentation
sender: which is FromUserName in the official documentation
type: message type
timestamp: message timestamp
Text Type
Text type has an extra data: content.
Image Type
Image type has an extra data: picurl.
Link Type
Link type has extra data:
title: article title
description: article description
url: original url of the article
Location Type
Location type has extra data:
location_x
location_y
scale
label
Event Type
Event type has extra data:
event
event_key
latitude
longitude
precision
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
Built Distributions
File details
Details for the file Flask-Weixin-0.4.0.tar.gz
.
File metadata
- Download URL: Flask-Weixin-0.4.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8b5b79470522aafc71bbd23769f3e394f1b5ced00bc874a6d84d3021b62e393d |
|
MD5 | ad66ef08d8073ceabb00f315269cd517 |
|
BLAKE2b-256 | ccdadb4d715c3fd67db064cd67775cda933df0e0a1aa56a390109f6a31d8cc56 |
File details
Details for the file Flask_Weixin-0.4.0-py3.3.egg
.
File metadata
- Download URL: Flask_Weixin-0.4.0-py3.3.egg
- Upload date:
- Size: 10.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 278a39d2475b992d1ef91fe1bcef95cebccebedf401ef5500d7bef827b799e6c |
|
MD5 | a91dae62a63197ba9d50e9beb2e5034c |
|
BLAKE2b-256 | 3feed9adb96b4f324d150a89b504dec15402b4ab9e71ae5f87e9d0bfd6631e31 |
File details
Details for the file Flask_Weixin-0.4.0-py2.py3-none-any.whl
.
File metadata
- Download URL: Flask_Weixin-0.4.0-py2.py3-none-any.whl
- Upload date:
- Size: 7.5 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8216ded46cecdc7cecbacdc51583c494f7bf95bff97af42b61d4cf901b0a7fc8 |
|
MD5 | 05f3514a90ca5f0b451bd7f845ac465b |
|
BLAKE2b-256 | 68b948a35077a02dd55d2641a8602fa67f11c8dea79a31043047de65bbb2d025 |