微信公众号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"

运行结果:

在浏览器输入网址: http://weixin.ithomer.net

http___img0.tuicool.com_JNbMba.png

验证微信

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

在SAE上,已经配置了Token(sunboy_2050),URL连接为  http://weixin.ithomer.net/weixin

http___img1.tuicool.com_RvueAr.png

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

http___img2.tuicool.com_A3mmQj.png

参考推荐:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值