Skip to content

Commit

Permalink
Adds proxy example
Browse files Browse the repository at this point in the history
  • Loading branch information
desmondmorris committed Jan 25, 2015
1 parent 1cd9f67 commit 8a7431b
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions examples/README.md
Expand Up @@ -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({
Expand All @@ -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);
}
});
```

0 comments on commit 8a7431b

Please sign in to comment.