Skip to main content

Weixin for Flask.

Project description

https://travis-ci.org/lepture/flask-weixin.png?branch=master https://coveralls.io/repos/lepture/flask-weixin/badge.png?branch=master

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.

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

Flask-Weixin-0.3.0.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

Flask_Weixin-0.3.0-py2.py3-none-any.whl (7.3 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file Flask-Weixin-0.3.0.tar.gz.

File metadata

File hashes

Hashes for Flask-Weixin-0.3.0.tar.gz
Algorithm Hash digest
SHA256 a51a248474ce0399f58c9443f4487bba78cfe5e72542a2de8a8c5bc3a24cf061
MD5 00d5f440504629d377f3aedeb931fb59
BLAKE2b-256 5c2721ecbf221cc6e01e4437d5befce0a56f257af4294cd6bd8464337aed2550

See more details on using hashes here.

File details

Details for the file Flask_Weixin-0.3.0-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for Flask_Weixin-0.3.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 e428e9f9e445589ee98fcd1427fd78f280e781883a8d8f9c6a186a277972c337
MD5 19d23f8bcc510080962996d719865d2c
BLAKE2b-256 dfe3c0447274c8d8eb4496bcff96d6ff6fb6a79ecb4497a31afc77579c1885e1

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