100字范文,内容丰富有趣,生活中的好帮手!
100字范文 > 微信公众号sae服务器搭建 SAE 搭建微信公众平台

微信公众号sae服务器搭建 SAE 搭建微信公众平台

时间:2022-04-30 05:20:56

相关推荐

微信公众号sae服务器搭建 SAE 搭建微信公众平台

index.wsgi

# coding: UTF-8

import sae

import os

import web

from weixinInterface import WeixinInterface

urls = (

'/', 'Hello',

'/weixin','WeixinInterface'

)

class Hello:

def GET(self):

return ("你好, Sunboy_2050")

app = web.application(urls, globals()).wsgifunc()

application = sae.create_wsgi_app(app)

weixinInterface.py

#coding:UTF-8

import hashlib

import web

class WeixinInterface:

def GET(self):

data = web.input()# 获取输入参数

signature = data.signature

timestamp = data.timestamp

nonce = data.nonce

echostr = data.echostr

token="sunboy_2050"# 自己的token

list=[token,timestamp,nonce]# 字典序排序

list.sort()

sha1=hashlib.sha1()# sha1加密算法

map(sha1.update, list)

hashcode=sha1.hexdigest()

if hashcode == signature:# 如果是来自微信的请求,则回复echostr

return echostr# print "true"

运行结果:

在浏览器输入网址:

验证微信

成为微信公众平台开发者,需要进行验证,输入URL和Token

在SAE上,已经配置了Token(sunboy_2050),URL连接为 /weixin

点击“提交”按钮,自动进行验证,验证结果如下:

参考推荐:

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。