本文整理汇总了Python中twitdao.Twitdao.mentions方法的典型用法代码示例。如果您正苦于以下问题:Python Twitdao.mentions方法的具体用法?Python Twitdao.mentions怎么用?Python Twitdao.mentions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitdao.Twitdao
的用法示例。
在下文中一共展示了Twitdao.mentions方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get
# 需要导入模块: from twitdao import Twitdao [as 别名]
# 或者: from twitdao.Twitdao import mentions [as 别名]
def get(self):
params = self.params(["since_id", "max_id", "count", "page", "trim_user", "include_rts", "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 = token_user
timeline = td.mentions(**params)
self.render(
"mentions-timeline.html",
{
"token": token,
"token_user": token_user,
"owner_user": owner_user,
"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": "mentions",
},
)
示例2: get
# 需要导入模块: from twitdao import Twitdao [as 别名]
# 或者: from twitdao.Twitdao import mentions [as 别名]
def get(self, slug):
params=self.params([
'since_id',
'max_id',
'count',
'page',
'trim_user',
'include_rts',
'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)
timeline = td.mentions(**params)
tweets = self.render('ajax/mentions.html', {
'token':token,
'token_user':token_user,
'timeline':timeline,
}, out=False)
if slug == '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/mentions?%s' % urlencode(next_params)
}))