我正在使用Twit npm模块来流式传输特定位置的推文。如果我使用San Francisco
,New York City
之类的位置,效果很好,但是当我放置Kuala Lumpur
或其他任何位置时,效果却不佳,并且出现错误:
错误:
Error: Bad Twitter streaming request: 406
at Object.exports.makeTwitError (/home/Twitter/node_modules/twit/lib/helpers.js:74:13)
at Request.<anonymous> (/home/Twitter/node_modules/twit/lib/streaming-api-connection.js:96:29)
at emitOne (events.js:121:20)
at Request.emit (events.js:211:7)
at IncomingMessage.<anonymous> (/home/himnashu/MyProjects/Twitter/node_modules/request/request.js:1083:12)
at Object.onceWrapper (events.js:313:30)
at emitNone (events.js:111:20)
at IncomingMessage.emit (events.js:208:7)
at endReadableNT (_stream_readable.js:1064:12)
at _combinedTickCallback (internal/process/next_tick.js:138:11)
at process._tickCallback (internal/process/next_tick.js:180:9)
代码:
var Twit = require('twit')
var T = new Twit({
consumer_key: '...',
consumer_secret: '...',
access_token: '...',
access_token_secret: '...',
timeout_ms: 60*10, // optional HTTP request timeout to apply to all requests.
strictSSL: true, // optional - requires SSL certificates to be valid.
})
var kualaLumpur = [ 3.1384803, 101.5470242, 3.139003, 101.686855 ]
var stream = T.stream('statuses/filter', { locations: kualaLumpur })
stream.on('tweet', function (tweet) {
console.log(tweet)
})