当前位置: 首页>>代码示例>>Python>>正文


Python auth.OAuthHandler类代码示例

本文整理汇总了Python中weibopy.auth.OAuthHandler的典型用法代码示例。如果您正苦于以下问题:Python OAuthHandler类的具体用法?Python OAuthHandler怎么用?Python OAuthHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了OAuthHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: press_sina_weibo

def press_sina_weibo():  
    ''''' 
    调用新浪微博Open Api实现通过命令行写博文,功能有待完善 
    author: socrates 
    date:2012-02-06 
    新浪微博:@没耳朵的羊 
    '''  
    sina_weibo_config = configparser.ConfigParser()  
    #读取appkey相关配置文件  
    try:  
        sina_weibo_config.readfp(open('sina_weibo_config.ini'))  
    except configparser.Error:  
        print ('read sina_weibo_config.ini failed.')  
      
    #获取需要的信息  
    consumer_key = sina_weibo_config.get("userinfo","CONSUMER_KEY")  
    consumer_secret =sina_weibo_config.get("userinfo","CONSUMER_SECRET")  
    token = sina_weibo_config.get("userinfo","TOKEN")  
    token_sercet = sina_weibo_config.get("userinfo","TOKEN_SECRET")  
  
  
    #调用新浪微博OpenApi(python版)  
    auth = OAuthHandler(consumer_key, consumer_secret)  
    auth.setAccessToken(token, token_sercet)  
    api = API(auth)  
    return api;   
开发者ID:misaka20001,项目名称:mywork,代码行数:26,代码来源:sina_friends.py

示例2: GET

    def GET(self):
        access_token=session.get('access_token',None)
        if not access_token:
            auth = OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET,web.ctx.get('homedomain')+'/callback')
            auth_url = auth.get_authorization_url()
            session.request_token=auth.request_token
            web.seeother(auth_url)
        else:
            auth =OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
            auth.access_token=access_token
            api=API(auth)
            user=api.verify_credentials()
            user_timeline=user.timeline(count=10)

            print "current user is ",user.screen_name
            hot_list=get_hot_list()
            for user_tweet in user_timeline:
                try:
                    hot_list.append(tuple([user_tweet.user.screen_name,
                                            user_tweet.mid,
                                            user_tweet.text,
                                            user_tweet.source,
                                            user_tweet.created_at,
                                            None,
                                            None]))
                except AttributeError:
                    #no retweet_statues
                    continue
            return render.index(user.screen_name,user.id,hot_list)
开发者ID:hewigovens,项目名称:tisualize,代码行数:29,代码来源:index.py

示例3: press_sina_weibo

def press_sina_weibo():  
    ''''' 
    调用新浪微博Open Api实现通过命令行写博文,功能有待完善 
    author: socrates 
    date:2012-02-06 
    新浪微博:@偶是正太 
    '''  
    sina_weibo_config = configparser.ConfigParser()  
    #读取appkey相关配置文件  
    try:  
        sina_weibo_config.readfp(open('sina_weibo_config.ini'))  
    except configparser.Error:  
        print ('read sina_weibo_config.ini failed.')  
      
    #获取需要的信息  
    consumer_key = sina_weibo_config.get("userinfo","CONSUMER_KEY")  
    consumer_secret =sina_weibo_config.get("userinfo","CONSUMER_SECRET")  
    token = sina_weibo_config.get("userinfo","TOKEN")  
    token_sercet = sina_weibo_config.get("userinfo","TOKEN_SECRET")  
  
    #调用新浪微博OpenApi(python版)  
    auth = OAuthHandler(consumer_key, consumer_secret)  
    auth.setAccessToken(token, token_sercet)  
    api = API(auth)  
  
    #通过命令行输入要发布的内容  
    weibo_content = input('Please input content:')  
    status = api.update_status(status=weibo_content)  
    print ("Press sina weibo successful, content is: %s" % status.text) 
开发者ID:misaka20001,项目名称:mywork,代码行数:29,代码来源:sina_test.py

示例4: mainPage

def mainPage(request):
    session = get_current_session()
    access_token_key = session['access_token_key']
    access_token_secret = session['access_token_secret']
    oauth_verifier = request.GET.get('oauth_verifier', '')
    get_absolute_path(request)
    if not access_token_key:
        #params['test'] = reverse('sinaweibo.views.login', args=[], kwargs={})#, current_app=context.current_app)        
        login_url = reverse('sinaweibo.views.login', args=[], kwargs={})
        #return shortcuts.render_to_response('test.html', params)
        return http.HttpResponseRedirect(login_url)
    else:
        auth = OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
        auth.setToken(access_token_key, access_token_secret)
        api = API(auth)
        
        #myself = api.get_user(id=1894001933)
        #screen_name = myself. __getattribute__('screen_name')
        myweibo = []
        myweibo_obj = api.user_timeline(count=20, page=1)
        for weibo in myweibo_obj:
            myweibo.append({'text': weibo.text, 
                            'created_at': weibo.created_at, 
                            'retweeted_status': hasattr(weibo, 'retweeted_status') and weibo.retweeted_status or None,
                            'source': weibo.source})
        wrapper__at(myweibo)
        params = {}
        
        params['user'] = api.verify_credentials()
        params['result'] = myweibo
        template = get_template_uri(appContext, 'weibo.html')
        return shortcuts.render_to_response(template, params)
开发者ID:zy-sunshine,项目名称:sunblackshineblog,代码行数:32,代码来源:views.py

示例5: addFavorite

def addFavorite(status_id):
    auth = OAuthHandler(APP_KEY, APP_SECRET)
    # Get currrent user access token from session
    access_token = session['oauth_access_token']
    auth.setToken(access_token.key, access_token.secret)
    api = API(auth)
    api.create_favorite(status_id)
开发者ID:SAEPython,项目名称:Save2Weibo,代码行数:7,代码来源:app.py

示例6: getData

class getData():

    def __init__(self,flaglt):
	APP_KEY = '190802369'
        APP_SECRET = 'fb4ce1e3a4b049abb75f104d7a7439d7'
        BACK_URL = ''
        self.auth = OAuthHandler(APP_KEY,APP_SECRET,BACK_URL)
        with open('entry.pickle','rb') as f:
            entry = pickle.load(f)
        self.key = entry['key']
        self.secret = entry['secret']
	
	self.followflag = flaglt[0]
	self.friendflag = flaglt[1]
	self.weiboflag = flaglt[2]

    def getFlagStatus(self):
	return (self.followflag,self.friendflag,self.weiboflag)
	
    def searchUser(self,name):
        self.auth.setToken(self.key,self.secret)
        api = API(self.auth)
        try :
            user = api.get_user(screen_name=name)
	    #print user.id
            data = (user.screen_name.encode('utf-8'),user.location.encode('utf-8'),user.followers_count,user.friends_count,user.statuses_count,user.profile_image_url)
            return data
        except Exception ,e:
            pass
开发者ID:shch,项目名称:weibo,代码行数:29,代码来源:data.py

示例7: init_1st_step

 def init_1st_step(self):
     auth = OAuthHandler(APP_KEY, APP_SECRET, '')
     auth_url = auth.get_authorization_url()
     user.update_app('sina', self.email, request_token=auth.request_token.key,
             request_secret=auth.request_token.secret)
     log.debug(repr(user.get(self.email)))
     return auth_url
开发者ID:vincentwyshan,项目名称:VGA,代码行数:7,代码来源:sina.py

示例8: init_2nd_step

 def init_2nd_step(self, verifier_num):
     info = user.get_app('sina', self.email)
     auth = OAuthHandler(APP_KEY, APP_SECRET)
     auth.set_request_token(info.get('request_token'), info.get('request_secret'))
     access = auth.get_access_token(verifier_num)
     user.update_app('sina', self.email, access_token=access.key, access_secret=access.secret)
     return True
开发者ID:vincentwyshan,项目名称:VGA,代码行数:7,代码来源:sina.py

示例9: get

    def get(self):
        invitationCode = self.request.get('invitation_code')
        if not self.isValidInvitationCode(invitationCode):
            error_output(self, "<html><body>邀请码无效</body></html>", "text/html", 400)
            return
        auth = OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
        
        verifier = self.request.get("oauth_verifier").strip()
        twitterId = self.request.get("twitter_id").strip()
        if verifier == "" or twitterId == "":
            authUrl = auth.get_authorization_url()
            success_output(self, page_goto_sina_oauth % \
                {'url':authUrl, 
                 'invitation':invitationCode.encode('UTF-8'),
                 'token':auth.request_token.key, 
                 'secret':auth.request_token.secret})
        else:
            request_token = self.request.get("request_token")
            request_secret = self.request.get("request_secret")
            auth.set_request_token(request_token, request_secret)
            accessToken = auth.get_access_token(verifier)
            binding = SyncBinding.getOrInsertByInvitationCode(invitationCode)
            binding.lastTweetId = None
            binding.twitterId = twitterId
            binding.sinaAccessToken = accessToken.key
            binding.sinaAccessSecret = accessToken.secret
            binding.put()
            success_output(self, '''
<html><body>
<p>Twitter与新浪微博同步绑定成功</p>
<p>如需要修改绑定,请重新访问邀请链接</p>
</body></html>
            ''')
开发者ID:userid,项目名称:TwitterSinaSync,代码行数:33,代码来源:main.py

示例10: login

def login():
    callback = 'http://so2weibo.sinaapp.com/login_callback'

    auth = OAuthHandler(APP_KEY, APP_SECRET, callback)
    # Get request token and login url from the provider
    url = auth.get_authorization_url()
    session['oauth_request_token'] = auth.request_token
    # Redirect user to login
    return redirect(url)
开发者ID:SAEPython,项目名称:Save2Weibo,代码行数:9,代码来源:app.py

示例11: __init__

 def __init__(self):
     # 设定网页应用回调页面(桌面应用设定此变量为空)
     BACK_URL = ""
     # 验证开发者密钥.
     auth = OAuthHandler(APP_KEY, APP_SECRET, BACK_URL)
     # 设定用户令牌密钥.
     auth.setToken(TOKEN_KEY, TOKEN_SECRET)
     # 绑定用户验证信息.
     self.api = API(auth)
开发者ID:kwdhd,项目名称:zhan2weibo,代码行数:9,代码来源:weibo.py

示例12: GET

 def GET(self):
     oauth_token = web.input().oauth_token
     oauth_verifier = web.input().oauth_verifier
     auth = OAuthHandler(oauth.APP_KEY, oauth.APP_SECRET)
     auth.set_request_token(session.rtKey[web.ctx.ip], session.rtSec[web.ctx.ip])
     access_token = auth.get_access_token(oauth_verifier)
     session.atKey[web.ctx.ip] = access_token.key
     session.atSec[web.ctx.ip] = access_token.secret
     raise web.seeother('/sinaweibo/timeline')
开发者ID:vincentwyshan,项目名称:VGA,代码行数:9,代码来源:webinterface.py

示例13: get

 def get(self):
     recordtoken = OauthInfo(states="openAccount",service="sina",emailaddr="[email protected]")
     recordtoken.put()
     auth = OAuthHandler(CONSUMER_KEY_SINA, CONSUMER_SECRET_SINA,self.call_back_url+"?UID="+str(recordtoken.key()))
     url = auth.get_authorization_url()
     recordtoken.states = "request_token_got"
     recordtoken.fromOauthToken(auth.request_token)
     recordtoken.put()
     self.redirect(url)
开发者ID:qzhuyan,项目名称:nanomumu,代码行数:9,代码来源:tbotMain.py

示例14: WeiboAuthV1

def WeiboAuthV1(userinfo):
    api = None
    try:
        auth = OAuthHandler(WEIBO_APP_KEY, WEIBO_APP_SECRET)
        auth.setToken(userinfo.weibo_access_token, userinfo.weibo_access_token_secret)
        api = API(auth)
    except Exception as e:
        logging.info("WeiboAuth error %s " % e)
    return api
开发者ID:marvelliu,项目名称:flickr2weibo,代码行数:9,代码来源:auth.py

示例15: newmessage

 def newmessage(self, message, lat=None, long=None):
     log.debug('new message: %s' % message)
     auth = OAuthHandler(APP_KEY, APP_SECRET)
     info = user.get_app('sina', self.email)
     auth.setToken(info['access_token'], info['access_secret'])
     api = API(auth)
     api.update_status(message)
     log.debug('new message done.')
     return True
开发者ID:vincentwyshan,项目名称:VGA,代码行数:9,代码来源:sina.py


注:本文中的weibopy.auth.OAuthHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。