def weibo_auth(): keys = {'app_key','app_secret','redirect_uri','username','password'} for key in keys: if(request.form.has_key(key) == False): return jsonify( error=True, msg='mission param:'+key ) app_key = request.form['app_key'] app_secret = request.form['app_secret'] redirect_uri = request.form['redirect_uri'] username = request.form['username'] password = request.form['password'] app = WeiboAutoAuth(app_key,app_secret,redirect_uri,username,password) d = json.loads(app.get_access_token()) d['error'] = False return jsonify(d)
# -*- coding: utf8 -*- from weibo import WeiboAutoAuth app_key = "3530915833" # 请修改成您的app_key app_secret = "f34a9eb3404c7f99b5e8466e18ce9b6e" # 请修改成您的app_secret redirect_uri = "http://snsapi.sinaapp.com/auth.php" # 请修改成您的redirect_uri username = "" # 请修改成您的测试用户名 password = "" # 请修改成您的测试微博密码 api = WeiboAutoAuth(app_key, app_secret, redirect_uri, username, password) print api.get_access_token()
# -*- coding: utf8 -*- from weibo import WeiboAutoAuth app_key = '3530915833' #请修改成您的app_key app_secret = 'f34a9eb3404c7f99b5e8466e18ce9b6e' #请修改成您的app_secret redirect_uri = 'http://snsapi.sinaapp.com/auth.php' #请修改成您的redirect_uri username = '' #请修改成您的测试用户名 password = '' #请修改成您的测试微博密码 api = WeiboAutoAuth(app_key,app_secret,redirect_uri,username,password) print api.get_access_token()
from weibo import WeiboAutoAuth api = WeiboAutoAuth('你的app_key', '你的app_secret', '你的appredirect_uri', '微博用户名', '微博密码') print api.get_access_token()
api = TencentWeiboAutoAuth('app id','app_secret','app_redirect_uri','qq号','qq 密码') print api.get_access_token() print 'OpenId:',api.get_openid() print 'OpenKey:',api.get_openkey() ########NEW FILE######## __FILENAME__ = test # -*- coding: utf8 -*- from weibo import WeiboAutoAuth app_key = '3530915833' #请修改成您的app_key app_secret = 'f34a9eb3404c7f99b5e8466e18ce9b6e' #请修改成您的app_secret redirect_uri = 'http://snsapi.sinaapp.com/auth.php' #请修改成您的redirect_uri username = '' #请修改成您的测试用户名 password = '' #请修改成您的测试微博密码 api = WeiboAutoAuth(app_key,app_secret,redirect_uri,username,password) print api.get_access_token() ########NEW FILE######## __FILENAME__ = weibo # -*- coding: utf8 -*- import urllib import urllib2 import cookielib import requests from bs4 import BeautifulSoup class WeiboAutoAuth(object): ''' 新浪微博自动认证 '''