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


Python twitdao.Twitdao类代码示例

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


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

示例1: post

    def post(self, id):
        params = self.params(['include_entities'])
        
        token = md.get_default_access_token()
        if not token:
            self.write(json.dumps({
                'success':False,
                'info':'No access token avaliable.',
            }))
            return
        
        td = Twitdao(token)
        message = td.direct_messages_destroy(id=id, **params)

        if 'error' in message:
            self.write(json.dumps({
                'success':False,
                'info':message['error'],
            }))
        else:
            self.write(json.dumps({
                'success':True,
                'info':'OK',
                'message':message,
            }))
开发者ID:messiahxu,项目名称:Twitdao11,代码行数:25,代码来源:ajax.py

示例2: get

    def get(self, screen_name, slug, xlug):
        
        params = self.params(['since_id','max_id','per_page','page','include_entities'])

        token = md.get_default_access_token()
        if not token:
            self.redirect('/settings')
            return

        td = Twitdao(token)
        token_user = td.users_show_by_id(user_id = token.user_id)
        owner_user = td.users_show_by_screen_name(screen_name = screen_name)
        #ls = td.user_list_id_get(id=slug, screen_name=screen_name)
        timeline = td.user_list_id_statuses(id=slug, screen_name = screen_name, **params)

        tweets=self.render('ajax/list.html', {
            'token':token,
            'token_user':token_user,
            'owner_user':owner_user,
            #'list':ls,
            'timeline':timeline,
        },out=False)

        if xlug == 'refresh':
            next_params={}
            count=0
            if type(timeline) == list and len(timeline):
                next_params['since_id'] = str(timeline[0]['id'])
                count = len(timeline)
            else:
                tweets=''
                next_params['since_id'] = str(params['since_id'])
                count = 0

            self.write(json.dumps({
                'success':True,
                'info':'OK',
                'tweets':tweets,
                'params':next_params,
                'count':count,
            }))
        else:
            next_params={}
            count=0
            if type(timeline) == list and len(timeline):
                next_params['max_id'] = str(timeline[-1]['id']-1)
                count = len(timeline)
            else:
                tweets=''
                next_params['max_id'] = str(params['max_id'])
                count = 0

            self.write(json.dumps({
                'success':True,
                'info':'OK',
                'tweets':tweets,
                'params':next_params,
                'count':count,
                'href':'/t/%s/%s?%s'% (screen_name, slug, urlencode(next_params))
            }))
开发者ID:messiahxu,项目名称:Twitdao11,代码行数:60,代码来源:ajax.py

示例3: get

    def get(self, screen_name, slug):
        params = self.params(["since_id", "max_id", "per_page", "page", "include_entities"])

        token = md.get_default_access_token()
        if not token:
            self.redirect("/settings")
            return

        td = Twitdao(token)
        token_user = td.users_show_by_id(user_id=token.user_id)
        owner_user = td.users_show_by_screen_name(screen_name=screen_name)
        ls = td.user_list_id_get(id=slug, screen_name=screen_name)
        timeline = td.user_list_id_statuses(id=slug, screen_name=screen_name, **params)

        self.render(
            "list-timeline.html",
            {
                "token": token,
                "token_user": token_user,
                "owner_user": owner_user,
                "list": ls,
                "timeline": timeline,
                "max_id": str(timeline[-1]["id"] - 1) if type(timeline) == list and len(timeline) > 0 else None,
                "since_id": timeline[0]["id_str"] if type(timeline) == list and len(timeline) > 0 else None,
                "where": "list-timeline",
            },
        )
开发者ID:tongsu,项目名称:twitdao,代码行数:27,代码来源:main.py

示例4: get

    def get(self, id):
        params = self.params(['trim_user','include_entities'])

        token = md.get_default_access_token()
        if not token:
            self.write(json.dumps({
                'success':False,
                'info':'No access token avaliable.',
            }))
            return

        td = Twitdao(token)
        token_user = td.users_show_by_id(user_id = token.user_id)
        tweet = td.statuses_show(id=id, **params)
        tweet_html = self.render('ajax/user-tweet.html', {
            'token':token,
            #'token_user':token_user,
            'tweet':tweet,
        }, out=False)

        self.write(json.dumps({
            'tweet':tweet_html if 'error' not in tweet else None,
            'success':'error' not in tweet,
            'info':tweet['error'] if 'error' in tweet else 'OK',
        }))
开发者ID:messiahxu,项目名称:Twitdao11,代码行数:25,代码来源:ajax1.py

示例5: get

    def get(self):
        denied = self.param('denied', default_value=None)

        if denied:
            self.render('denied.html')
            return

        oauth_verifier = self.param('oauth_verifier')
        cookie_id = self.get_cookie('cid','')
        request_token = memcache.get(cookie_id)

        if not request_token or 'oauth_token' not in request_token:
            self.delete_cookie('cid')
            self.error(404)
            return

        td = Twitdao(md.AccessToken(
            oauth_token=request_token['oauth_token'],
            oauth_token_secret=request_token['oauth_token_secret']
        ))

        access_token = td.fetch_access_token(oauth_verifier)

        md.save_access_token(
            user_id=access_token['user_id'],
            screen_name=access_token['screen_name'],
            oauth_token=access_token['oauth_token'],
            oauth_token_secret=access_token['oauth_token_secret'],
            app_user = users.get_current_user()
        )

        self.delete_cookie('cid')
        self.redirect(self.param('url'))
开发者ID:messiahxu,项目名称:Twitdao11,代码行数:33,代码来源:settings.py

示例6: post

    def post(self):
        tk=self.param('tk')
        if not tk:
            self.error(404)
            return

        ds_type=self.param('ds_type')

        token = md.get_access_token(tk, users.get_current_user())
        if not token:
            self.redirect('/settings')
            return

        td=Twitdao(token)
        if ds_type == 'colors':
            params=self.params([
                'profile_background_color',
                'profile_text_color',
                'profile_link_color',
                'profile_sidebar_fill_color',
                'profile_sidebar_border_color',
                'include_entities',
            ])
            td.account_update_profile_colors(**params)
        elif ds_type == 'background':
            image=self.param('image')
            if image:
                params=self.params(['tile','include_entities'])
                for k in params:
                    params[k]=params[k].encode('utf-8')
                filename=self.request.POST[u'image'].filename.encode('utf-8')
                td.account_update_profile_background_image(('image', filename, image), **params)

        self.redirect('/settings/design?tk=%s' % tk)
开发者ID:messiahxu,项目名称:Twitdao11,代码行数:34,代码来源:settings.py

示例7: get

 def get(self):
     token = md.get_default_access_token()
     if not token:
         self.redirect("/settings")
         return
     td = Twitdao(token)
     token_user = td.users_show_by_id(user_id=token.user_id)
     owner_user = token_user
     self.render("mobile/upload.html", {"token": token, "token_user": token_user, "owner_user": owner_user})
开发者ID:tongsu,项目名称:twitdao,代码行数:9,代码来源:mobile.py

示例8: post

    def post(self, screen_name, slug):

        token = md.get_default_access_token()
        if not token:
            self.redirect("/settings")
            return

        td = Twitdao(token)
        td.user_list_id_subscribers_delete(screen_name=screen_name, list_id=slug)
        self.redirect("/t/%s/%s" % (screen_name, slug))
开发者ID:tongsu,项目名称:twitdao,代码行数:10,代码来源:main.py


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