本文整理汇总了Python中models.Tweet.since_id方法的典型用法代码示例。如果您正苦于以下问题:Python Tweet.since_id方法的具体用法?Python Tweet.since_id怎么用?Python Tweet.since_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Tweet
的用法示例。
在下文中一共展示了Tweet.since_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cronTopics
# 需要导入模块: from models import Tweet [as 别名]
# 或者: from models.Tweet import since_id [as 别名]
def cronTopics():
# res = urlfetch.fetch(
# url='https://api.twitter.com/oauth2/token',
# payload='grant_type=client_credentials',
# method=urlfetch.POST,
# headers={
# 'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
# 'Authorization': 'Basic {}'.format(bearer_token_encoded),
# },
# )
# app.logger.info(res)
#
# data = json.loads(res.content)
# app.logger.info('Data: {}'.format(data))
# if 'errors' in data:
# error = data['errors'][0]
# raise Exception('[{} {}] {}'.format(error['code'], error['label'], error['message']))
# access_token = data['access_token']
# token_type = data['token_type']
# bearer_token = '{}:{}'.format(consumer_key, consumer_secret)
# app.logger.info('bearer token: {}'.format(bearer_token))
# bearer_token_encoded = base64.b64encode(bearer_token)
# app.logger.info('bearer token encoded: {}'.format(bearer_token_encoded))
access_token = 'AAAAAAAAAAAAAAAAAAAAABcJYAAAAAAAVviSzyKtPYqYlHpZxoim6DHvfjI%3DU0slNkvBKQRynT62gbvQjEhAlE2PvzVZNia99xAdoJweI2OLqe'
# get topics
user_topics = User.query(projection=[User.topics], distinct=True).fetch()
topics = [user.topics[0] for user in user_topics]
app.logger.info('Topics fetched: {}'.format(topics))
for topic in topics:
# get since ID
since_id = Tweet.since_id(topic)
params = {'topic': topic, 'since_id': since_id}
app.logger.info('Created push queue for {}'.format(params))
taskqueue.add(url='/cron/remove/tweets', params=params)
mail.send_mail(
sender='[email protected]',
to='[email protected]',
subject='Cron Topics',
body='All {} topics pushed'.format(len(topics)),
)
app.logger.info('All {} topics pushed'.format(len(topics)))
return Response('OK')