Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ client.get('statuses/user_timeline', params, function(error, tweets, response) {

## Installation

`npm install twitter`
`npm install twitter-lang`

## Quick Start

Expand Down Expand Up @@ -162,6 +162,20 @@ client.stream('statuses/filter', {track: 'javascript'}, function(stream) {
});
```

## Restricting Language

```javascript
var Twitter = require('twitter');

var client = new Twitter({
consumer_key: '',
consumer_secret: '',
access_token_key: '',
access_token_secret: '',
language: 'en'
});
```

**Note** twitter stream several types of events, see [the docs](https://dev.twitter.com/streaming/overview/messages-types) for more info. There is no canonical way of detecting tweets versus other messages, but some users have had success with the following strategy.

```javascript
Expand Down
5 changes: 5 additions & 0 deletions lib/twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ function Twitter(options) {
access_token_key: null,
access_token_secret: null,
bearer_token: null,
language: null,
rest_base: 'https://api.twitter.com/1.1',
stream_base: 'https://stream.twitter.com/1.1',
user_stream_base: 'https://userstream.twitter.com/1.1',
Expand Down Expand Up @@ -99,6 +100,10 @@ Twitter.prototype.__buildEndpoint = function(path, base) {
endpoint += (path.split('.').pop() !== 'json') ? '.json' : '';
}

if (this.options.language) {
endpoint += '?language=' + this.options.language;
}

return endpoint;
};

Expand Down
Loading