本文整理汇总了Python中twitdao.Twitdao.statuses_update方法的典型用法代码示例。如果您正苦于以下问题:Python Twitdao.statuses_update方法的具体用法?Python Twitdao.statuses_update怎么用?Python Twitdao.statuses_update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitdao.Twitdao
的用法示例。
在下文中一共展示了Twitdao.statuses_update方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post
# 需要导入模块: from twitdao import Twitdao [as 别名]
# 或者: from twitdao.Twitdao import statuses_update [as 别名]
def post(self):
status = self.param('status')
params = self.params([
'in_reply_to_status_id',
'lat',
'long',
'place_id',
'display_coordinates',
'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)
tweet = td.statuses_update(status=status.encode('utf-8'), **params)
taskqueue.add(queue_name='cache', url='/q/update_user_cache', params={'tk':token.key(), 'user_id':token.user_id}, method="GET" )
self.write(json.dumps({
'success':'error' not in tweet,
'info':tweet['error'] if 'error' in tweet else 'OK',
'tweet':tweet if 'error' not in tweet else None,
}))
示例2: post
# 需要导入模块: from twitdao import Twitdao [as 别名]
# 或者: from twitdao.Twitdao import statuses_update [as 别名]
def post(self):
status = self.param("status")
params = self.params(
["in_reply_to_status_id", "lat", "long", "place_id", "display_coordinates", "trim_user", "include_entities"]
)
token = md.get_default_access_token()
if not token:
self.redirect("/settings")
return
td = Twitdao(token)
td.statuses_update(status=status.encode("utf-8"), **params)
taskqueue.add(
queue_name="cache",
url="/q/update_user_cache",
params={"tk": token.key(), "user_id": token.user_id},
method="GET",
)
self.redirect("/t")
示例3: post
# 需要导入模块: from twitdao import Twitdao [as 别名]
# 或者: from twitdao.Twitdao import statuses_update [as 别名]
def post(self):
media = self.param("media")
status = self.param("status")
token = md.get_default_access_token()
if not token:
self.redirect("/settings")
return
app_config = md.get_app_config()
td = Twitdao(token)
twitpic = twitpic2.TwitPic2(
consumer_key=app_config.consumer_key,
consumer_secret=app_config.consumer_secret,
access_token="oauth_token=%s&oauth_token_secret=%s" % (token.oauth_token, token.oauth_token_secret),
service_key=app_config.twitpic_api_key,
)
try:
if media:
filename = self.request.POST[u"media"].filename.encode("utf-8")
resp = twitpic.api_call(
"POST", "upload", {"message": status.encode("utf-8")}, files=[("media", filename, media)]
)
full_status = status + " " + resp["url"]
tweet_status = full_status
if len(full_status) - 140 > 0:
tweet_status = status[: 140 - len(resp["url"]) - 4] + "... " + resp["url"]
td.statuses_update(status=tweet_status.encode("utf-8"))
taskqueue.add(
queue_name="cache",
url="/q/update_user_cache",
params={"tk": token.key(), "user_id": token.user_id},
method="GET",
)
except Exception, e:
logging.debug(e)