本文整理汇总了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,
}))
示例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))
}))
示例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",
},
)
示例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',
}))
示例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'))
示例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)
示例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})
示例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))