Example of using WeChat API in the Python Bottle framework, pythonbottle

Source: Internet
Author: User

Example of using API in the Python Bottle framework, pythonbottle

It is estimated that Otaku is not familiar with this thing. After so many years of development, he finally made a friendly step to the open platform. I thought it would have a detailed api and Other interfaces. I was excited to apply for a public platform, and then began to find the location of various Apis ......

It took nearly an hour and still could not be found ......

Finally, I used the Google kill and finally found such a link. I went here. It's no more simple api documentation than that.

What is most incomprehensible is that there is no local development environment support and debugging should be conducted in the production environment every time.

The most gratifying thing is that the production environment debugging is complete several times.

The Python (bottle) version code is as follows:

#-*-Coding: UTF-8-*-from bottle import debug, default_app, run, get, request, postimport sys, OS, time, libxml2dom @ get ('/') def index (): return request. GET. get ('echostr') @ post ('/') def index_post (): for key, value in request. POST. allitems (): doc = libxml2dom. parseString (key) _ to = doc. xpath ('// fromusername') [0]. textContent _ from = doc. xpath ('// tousername') [0]. textContent # _ content = doc. xpath ('// Co Ntent ') [0]. textContent return "" <xml> <ToUserName> <! [CDATA [% s]> </ToUserName> <FromUserName> <! [CDATA [% s]> </FromUserName> <CreateTime> % s </CreateTime> <MsgType> <! [CDATA [text]> </MsgType> <Content> <! [CDATA [% s]> </Content> <FuncFlag> 0 </FuncFlag> </xml> "" % (_ to, _ from, int (time. time (), u'let me know. ') if _ name _ = "_ main _": # Interactive mode debug (True) port = int (sys. argv [1] if len (sys. argv)> 1 else 8888) run (host = '0. 0.0.0 ', port = port, reloader = True) else: # Mod WSGI launch OS. chdir (OS. path. dirname (_ file _) app = default_app ()

The demo directly looks at the figure:

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.