使用前请先详细阅读微信官方API
import urllib2
import urllibimport simplejson
'''
weixin API, fetch_user_info is a function is used for fetching user's 3rd party's informations; refresh_token function is used to\
access weixin's refresh token api to expand the access token's life.
'''
def get_requests(url,params):
url = urllib2.urlopen('%s?%s'%(url,params))
return url
class Weichat(object):
def __init__(self,appid,secret,callbackurl):
self.appid = appid
self.secret = secret
self.redirect_uri = callbackurl
def fetch_access_token(self,code):
self.code = code
dict = {}
dict['grant_type'] = 'authorization_code'
dict['code'] = self.code