def update( req ):
	ct = datetime.now()
	jsonupdatelist = []
	if req.user.userprofile.twitter_token and req.user.userprofile.twitter_secret:
		since = req.GET.get('twittersince')
		try:
			since = int( since )
		except Exception:
			return HttpResponse( "{\"status\":0}" )
		tweetlist = cu_twitter.get_tweets( cu_twitter.get_tweepy_api_wrapper( req.user.userprofile.twitter_token , req.user.userprofile.twitter_secret ) , sinceid = since , count = 999999 )
		for i in range( len( tweetlist ) ):
			s = tweetlist[i]
			jsonupdatelist.append( { "app": "twitter" , "text": cu_twitter.status_get_text( s ) , "dt": ( ct - cu_twitter.status_get_time( s ) ).total_seconds() / 60 , "author": "@" + cu_twitter.status_get_poster( s ).screen_name , "id": cu_twitter.status_get_id( s ) } )
	dt = json.dumps( {"status":1,"response":jsonupdatelist} )
	return HttpResponse( dt )
def post_twitter( req ):
	if req.POST.get("text"):
		cu_twitter.post_tweet( cu_twitter.get_tweepy_api_wrapper( req.user.userprofile.twitter_token , req.user.userprofile.twitter_secret ) , req.POST.get("text") )
	return redirect("/")