From 8a7431b2d71bdac264a299765a76a16ef80fa96d Mon Sep 17 00:00:00 2001 From: Desmond Morris Date: Sun, 25 Jan 2015 18:34:59 -0500 Subject: [PATCH] Adds proxy example --- examples/README.md | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/examples/README.md b/examples/README.md index 89e16404..338bf278 100644 --- a/examples/README.md +++ b/examples/README.md @@ -3,14 +3,13 @@ * Tweet * Search * [Streams](#streaming) -* Proxy +* [Proxy](#proxy) * Media * Authentication -## Streaming +## Streams ```javascript - var Twitter = require('../lib/twitter'); var client = new Twitter({ @@ -34,3 +33,30 @@ client.stream('statuses/filter', {track: 'twitter'}, function(stream){ }); }); ``` + +## Proxy + +To make requests behind a proxy, you must pass the proxy location through to the request object. This is done by adding a `request_options` object to the configuration object. + +```javascript +var Twitter = require('../lib/twitter'); + +var client = new Twitter({ + consumer_key: process.env.TWITTER_CONSUMER_KEY, + consumer_secret: process.env.TWITTER_CONSUMER_SECRET, + access_token_key: process.env.TWITTER_ACCESS_TOKEN_KEY, + access_token_secret: process.env.TWITTER_ACCESS_TOKEN_SECRET, + request_options: { + proxy: 'http://myproxyserver.com:1234' + } +}); + +/** + * Grab a list of favorited tweets + **/ +client.get('favorites/list', function(error, tweets, response){ + if (!error) { + console.log(tweets); + } +}); +```