[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

How do I change the tracking keyword for a twitter stream using the app.get

aryaksengupta

3/3/2015 10:34:00 AM

Hi everyone,

I am new to Nodejs and Socket.io. I have worked through a tutorial which describes how both the technologies work together. The link to the tutorial is this :--- > Build a real-time Twitter stream

and the code for the tutorial is posted at github :---> Code of react-tweets.

Everything works fine in the tutorial and I also have no issues in understanding the code since the code is well commented.

In the server.js file, the tracking keyword which is "javascript" is manually fed into the "twit" object. i.e. here is the code for it.

twit.stream('statuses/filter',{ track: 'javascript'}, function(stream){
streamHandler(stream,io);
});

But I want to make a minor alteration in the code to make the application a bit more versatile. I want to change the tracking keyword dynamically using the URL entered by the user.

For example, if the URL entered is http://localhost/football, then automatically I want the track keyword to be changed to "football". The code should look like

twit.stream('statuses/filter',{ track: 'football'}, function(stream){
streamHandler(stream,io);
});

Now, I tried to set this object inside the app.get("/cricket", twit.stream.......); function but I get an error "Expected callback got object" .

How do I change the above mentioned code to achieve this?. Please let me know.

Thanks a lot.
13 Answers

Evertjan.

3/3/2015 12:01:00 PM

0

aryaksengupta@gmail.com wrote on 03 mrt 2015 in comp.lang.javascript:

> I am new to Nodejs and Socket.io. I have worked through a tutorial which
> describes how both the technologies work together.

Dear Aryak Sengupta,

This NG is about Javascript, which most of us think is a computer language.

> Nodejs and Socket.io ... technologies

Methinks they are libraries, not technologies,
but then I could be wrong, as that is just semantics.

However this Usenet NG is not a helpdesk,
and certainly not a helpdesk for specific libraries.

> Thanks a lot.

For what?

Please add a signature.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Scott Sauyet

3/4/2015 3:28:00 PM

0

aryaksengupta@gmail.com wrote:
> I am new to Nodejs and Socket.io. I have worked through a tutorial
> which describes how both the technologies work together.

This one?:

<https://scotch.io/tutorials/build-a-real-time-twitter-stream-with-node-and-re...

> Everything works fine in the tutorial and I also have no issues in
> understanding the code since the code is well commented.

Well, it seems not, or you probably wouldn't have this question! :-)

> [ ... ]
> Now, I tried to set this object inside the
> app.get("/cricket", twit.stream.......); function but I get an error
> "Expected callback got object" .

Well if you're passing the output of `twit.stream` as the second parameter
to `app.get`, then you do need to reread that tutorial. `app.get` is
expecting a route function there:

function(req, res) {
// parse req
// res.render(...) or res.send(...) or other possibilities
}

HTH,

-- Scott

Scott Sauyet

3/4/2015 3:43:00 PM

0

Evertjan. wrote:
> aryaksengupta@gmail.com wrote:
>
>> I am new to Nodejs and Socket.io. I have worked through a tutorial which
>> describes how both the technologies work together.

> Methinks they are libraries, not technologies,
> [ ... ] However this Usenet NG is not a helpdesk,
> and certainly not a helpdesk for specific libraries.

By that same logic, should we avoid discussion of DOM-related questions,
as they only have to do with one possible host environment for ECMAScript
languages? Should we skip `setTimeout` and the like? It might get
pretty quiet here.

-- Scott

Evertjan.

3/4/2015 4:37:00 PM

0

Scott Sauyet <scott.sauyet@gmail.com> wrote on 04 mrt 2015 in
comp.lang.javascript:

> Evertjan. wrote:
>> aryaksengupta@gmail.com wrote:
>>
>>> I am new to Nodejs and Socket.io. I have worked through a tutorial which
>>> describes how both the technologies work together.
>
>> Methinks they are libraries, not technologies,
>> [ ... ] However this Usenet NG is not a helpdesk,
>> and certainly not a helpdesk for specific libraries.
>
> By that same logic, should we avoid discussion of DOM-related questions,
> as they only have to do with one possible host environment for ECMAScript
> languages? Should we skip `setTimeout` and the like? It might get
> pretty quiet here.

Wrong, those are platforms, not libraries.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Christoph M. Becker

3/4/2015 5:42:00 PM

0

Evertjan. wrote:

> Scott Sauyet <scott.sauyet@gmail.com> wrote on 04 mrt 2015 in
> comp.lang.javascript:
>
>> Evertjan. wrote:
>>> aryaksengupta@gmail.com wrote:
>>>
>>>> I am new to Nodejs and Socket.io. I have worked through a tutorial which
>>>> describes how both the technologies work together.
>>
>>> Methinks they are libraries, not technologies,
>>> [ ... ] However this Usenet NG is not a helpdesk,
>>> and certainly not a helpdesk for specific libraries.
>>
>> By that same logic, should we avoid discussion of DOM-related questions,
>> as they only have to do with one possible host environment for ECMAScript
>> languages? Should we skip `setTimeout` and the like? It might get
>> pretty quiet here.
>
> Wrong, those are platforms, not libraries.

The DOM is a platform? I'll be blowed!

--
Christoph M. Becker

Evertjan.

3/4/2015 6:47:00 PM

0

"Christoph M. Becker" <cmbecker69@arcor.de> wrote on 04 mrt 2015 in
comp.lang.javascript:

>> Wrong, those are platforms, not libraries.
>
> The DOM is a platform? I'll be blowed!

You are free to smell your own wind.

But yes, depending on definition,
when a language has all it's interface
on a platform like the DOM,
why not call a rose a a sweetsmelling rose?


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Christoph M. Becker

3/4/2015 7:29:00 PM

0

Evertjan. wrote:

> "Christoph M. Becker" <cmbecker69@arcor.de> wrote on 04 mrt 2015 in
> comp.lang.javascript:
>
>>> Wrong, those are platforms, not libraries.
>>
>> The DOM is a platform? I'll be blowed!
>
> You are free to smell your own wind.

Very funny, as usual. ;)

> But yes, depending on definition,
> when a language has all it's interface
> on a platform like the DOM,
> why not call a rose a a sweetsmelling rose?

We're not philosophizing here (this is comp.lang.javascript), so back to
facts. The W3C (being responsible for the standardization of the DOM)
states[1]:

| This specification defines the Document Object Model Level 2, a
| platform- and language-neutral interface [...]

How could a platform-neutral interface be a platform? (Hint: this is a
rhetoric question.)

[1] <http://www.w3.org/TR/DOM-Le...

--
Christoph M. Becker

Scott Sauyet

3/4/2015 7:35:00 PM

0

Evertjan. wrote:
> Scott Sauyet wrote:
>> Evertjan. wrote:
>> By that same logic, should we avoid discussion of DOM-related questions,
>> as they only have to do with one possible host environment for ECMAScript
>> languages? Should we skip `setTimeout` and the like? It might get
>> pretty quiet here.
>
> Wrong, those are platforms, not libraries.

That seems a very odd definition of "platform". Very odd. Web browsers
provide a host environment for Javascript, and supply a number of APIs
(DOM, History, XHR, to name a few.) But those APIs are not part of the
core language itself. Hint: they're not mentioned in the spec.

The underlying question is why do you feel the need to police what
portions of the wider Javascript environment people should discuss here?

-- Scott

Evertjan.

3/4/2015 7:39:00 PM

0

"Christoph M. Becker" <cmbecker69@arcor.de> wrote on 04 mrt 2015 in
comp.lang.javascript:

>| This specification defines the Document Object Model Level 2, a
>| platform- and language-neutral interface [...]
>
> How could a platform-neutral interface be a platform? (Hint: this is a
> rhetoric question.)

Nonsense, you just want so very much think you are right, but you are not.

Just like a table, while not defined by the platform it stands on,
can be a platform itself for cups and spoons,
a "a platform-neutral interface" can "sit on" different platforms,
meaning different browsers, and even so be a platform for Javascript
and other languages.


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Evertjan.

3/4/2015 7:45:00 PM

0

Scott Sauyet <scott.sauyet@gmail.com> wrote on 04 mrt 2015 in
comp.lang.javascript:

> The underlying question is why do you feel the need to police what
> portions of the wider Javascript environment people should discuss here?

"need to police".

To be effective usenet NGs should be kept on topic,
and this can only be maintained by the users.

So while we can discuss the extent of the on-topic-ness,
the maintaining is part of the NG user's job.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)