新手,所以很坑的,连续踩坑
*# csrf_token
django默认有csrf,所以微信平台发POST数据的时候,需要自行添加csrf的key值,如下
from django.views.decorators.csrf import csrf_exempt# 这里用到python的函数修饰手法@csrf_exemptdef some_function_deal_with_request(): ...
*# xml CDATA minidom
python默认的xml库里面
*# get post
专门为微信的get,post写了一个小函数,本来准备分开的
def url_get_post( url, get = False, post = False):
'''be careful: return response.read()'''
from urllib import urlopen, urlencode
url = '%s?%s' % ( url, urllib.urlencode( get)) if get else url
req = ( url, urllib.urlencode( post)) if post else url
return urllib.urlopen( req).read()