Examples of using the WeChat API in the Python bottle framework

Source: Internet
Author: User
Tags cdata
This thing estimated that the otaku few unfamiliar bar, after so much more than two years of development finally to open the platform to cross a friendly step. The egg hurt thought will be a detailed API and other interfaces, excited to apply for the public platform, and then began to find the location of various APIs ...

It took nearly one hours, still not found ...

Finally, using the Google Big kill device, finally found such a link. I have a go, there is no simpler than this API documentation.

The most incomprehensible is: there is no local development environment support, every time should be placed in the production environment to debug.

The most gratifying thing is: the two methods, production environment debugging a few times will be finished.

The Python (bottle) version of the 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.x Path ('//tousername ') [0].textcontent #_content = Doc.xpath ('//content ') [0].textcontent return ' ""
 
   
    
    %s 0 
    %s 
 
    
    %s 
 
    
    text 
 
    
    %s 
 
    
 
 
 
 
 
 

  
 "" "% (_to, _from, int (Time.time ()), U ' I got a Go ') if __name__ = =" __main__ ": # Interactive Mode Debug (True) port = Int (sys.ar GV[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 looks directly at the diagram:

  • 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.