def get_api_limit(request): auth = setOAuth(request) api = tweepy.API(auth_handler=auth) try: api_limit = api.rate_limit_status() except Exception, e: return HttpResponseServerError()
def get_sent_direct_messages(request): auth = setOAuth(request) api = tweepy.API(auth_handler=auth) try: sent_direct_messages = api.sent_direct_messages(count = 30, include_entities=True) except Exception, e: return HttpResponseServerError()
def get_mentions(request): auth = setOAuth(request) api = tweepy.API(auth_handler=auth) try: mentions = api.mentions(count = 50, since_id=request.session.get('mentions_since_id'), include_entities=True) except Exception, e: return HttpResponseServerError()
def update_status(request): auth = setOAuth(request) api = tweepy.API(auth_handler=auth) try: api.update_status(status=request.GET.get('q'), in_reply_to_status_id=request.GET.get('in_reply_to_status_id')) except Exception, e: print "発言失敗したっぽい" return HttpResponseServerError()
def get_lists(request): auth = setOAuth(request) api = tweepy.API(auth_handler=auth) try: lists = api.lists() except Exception, e: print e return HttpResponseServerError()
def get_home_timeline(request): auth = setOAuth(request) api = tweepy.API(auth_handler=auth) try: home_timeline = api.home_timeline(count = 200, since_id=request.session.get('home_timeline_since_id'), include_entities=True) except Exception, e: print "取得失敗したっぽい" return HttpResponseServerError()
def get_list_timeline(request, list_owner, list_name): auth = setOAuth(request) api = tweepy.API(auth_handler=auth) rts = request.GET.get('rts') try: list_timeline = api.list_timeline(owner=list_owner, slug=list_name, count = 200, include_entities=True, include_rts=rts) except Exception, e: return HttpResponseServerError()
def toggleFav(request): auth = setOAuth(request) api = tweepy.API(auth_handler=auth) tweet_id = request.GET.get('id') #fav状態をチェックする try: favorited = api.get_status(tweet_id).favorited except Exception, e: return HttpResponseServerError()
def toggleRT(request): auth = setOAuth(request) api = tweepy.API(auth_handler=auth) tweet_id = request.GET.get('id') #TODO:他のクライアントからRTされた場合のRTの取り消し #RT状態をチェックする try: retweeted= api.get_status(tweet_id).retweeted except Exception, e: return HttpResponseServerError()