1

I'm trying to test this code to get a real-time streaming of tweets from Twitter:

var PubNub = require('pubnub')

var pubnubTwitter = new PubNub({
    subscribeKey: "sub-c-788-redacted",
})

pubnubTwitter.addListener({
    message: function(m) {
    var msg = m.message;
        if (msg.text.match(/([T|t]rump|[P|p][O|o][T|t][U|u][S|s])/g)) {
            console.log(msg.text);
        }
    }
})

pubnubTwitter.subscribe({
    channels: ['pubnub-twitter'],
})

I'm not sure if this is the right way to use the key that is provided by PunNub and not mine?

Also, is filtering tweets is an option in PubNub? "like the method in (Tweepy library in python)" Because I only want tweets from specific country and in specific language.

Thank you in advance.

Craig Conover
  • 4,710
  • 34
  • 59
user8423460
  • 125
  • 2
  • 12
  • 1
    PubNub does not provide a Twitter data feed for real world use. It is just a sample app of how you might do it. However, the server side code is not exposed (for various reasons) that consumes the Twitter data that is then published on PubNub. It is up to you to signup for a Twitter developer account and implement the server side portion. – Craig Conover Jan 29 '18 at 18:24

1 Answers1

0

PubNub Twitter Stream Sample App

Filtering tweets is not a built-in option in PubNub, rather, PubNub provides a Twitter Stream sample app that shows you how you might use the Twitter API in your server side application to receive Twitter updates and then publish them to different channels in PubNub for your subscriber clients to receive and display or react to those updates as you desire. Another example is Twitter sentiment analysis.

The server side code is not exposed as that is purely a Twitter API solution with PUbNub publish upon tweet receipt. It is up to you to signup for a Twitter developer account and implement the server side portion.

Community
  • 1
  • 1
Craig Conover
  • 4,710
  • 34
  • 59