#NEWLINE# def twitter_request( self , path , callback , access_token = None , post_args = None , **args ) : #NEWLINE# #INDENT# 'Fetches the given API path, e.g., "/statuses/user_timeline/btaylor"\n\n        The path should not include the format (we automatically append\n        ".json" and parse the JSON output).\n\n        If the request is a POST, post_args should be provided. Query\n        string arguments should be given as keyword arguments.\n\n        All the Twitter methods are documented at\n        http://apiwiki.twitter.com/Twitter-API-Documentation.\n\n        Many methods require an OAuth access token which you can obtain\n        through authorize_redirect() and get_authenticated_user(). The\n        user returned through that process includes an \'access_token\'\n        attribute that can be used to make authenticated requests via\n        this method. Example usage:\n\n        class MainHandler(tornado.web.RequestHandler,\n                          tornado.auth.TwitterMixin):\n            @tornado.web.authenticated\n            @tornado.web.asynchronous\n            def get(self):\n                self.twitter_request(\n                    "/statuses/update",\n                    post_args={"status": "Testing Tornado Web Server"},\n                    access_token=user["access_token"],\n                    callback=self.async_callback(self._on_post))\n\n            def _on_post(self, new_entry):\n                if not new_entry:\n                    # Call failed; perhaps missing permission?\n                    self.authorize_redirect()\n                    return\n                self.finish("Posted a message!")\n\n        ' #NEWLINE# url = ( ( 'http://twitter.com' + path ) + '.json' ) #NEWLINE# if access_token : #NEWLINE# #INDENT# all_args = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# all_args . update ( args ) #NEWLINE# all_args . update ( ( post_args or { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } ) ) #NEWLINE# consumer_token = self . _oauth_consumer_token ( ) #NEWLINE# method = ( 'POST' if ( post_args is not None ) else 'GET' ) #NEWLINE# oauth = self . _oauth_request_parameters ( url , access_token , all_args , method = method ) #NEWLINE# args . update ( oauth ) #NEWLINE# #UNINDENT# if args : #NEWLINE# #INDENT# url = make_full_url ( url , args ) #NEWLINE# #UNINDENT# callback = self . async_callback ( self . _on_twitter_request , callback ) #NEWLINE# http = httpclient . AsyncHTTPClient ( ) #NEWLINE# if ( post_args is not None ) : #NEWLINE# #INDENT# http . fetch ( url , method = 'POST' , body = urllib . urlencode ( post_args ) , callback = callback ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# http . fetch ( url , callback = callback )