Note that there are some explanatory texts on larger screens.

plurals
  1. POCreating a persistant connection to twitter stream API using R
    primarykey
    data
    text
    <p>I am presently using the streamR package in R to stream tweets from the filter stream in twitter. I have a handshaken ROAuth object that I use for this. My piece of code looks like:</p> <pre><code># load the Twitter auth object load("twitter_oAuth3.RData") load("keywords3.RData") streamTweet = function(){ require(streamR) require(ROAuth) stack = filterStream(file.name="",track=keywords,timeout=500,oauth=twitter_oAuth) return(stack) } </code></pre> <p>I wanted to create a real time application, which involves dumping these tweets into an activeMQ topic. My code for that is:</p> <pre><code>require(Rjms) # Set logger properties url = "tcp://localhost:61616" type = "T" name = "TwitterStream" # initialize logger topicWriter = initialize.logger(url,type,name) topicWrite = function(input){ # print("writing to topic") to.logger(topicWriter,input,asString=TRUE,propertyName='StreamerID',propertyValue='1') return() } logToTopic = function(streamedStack){ # print("inside stack-writer") stacklength = length(streamedStack) print(c("Length: ",stacklength)) for(i in 1:stacklength){ print(c("calling for: ",i)) topicWrite(streamedStack[i]) } return() } </code></pre> <p>Now my problem is that of the timeout that <code>filterStream()</code> needs. I looked under the hood, and found this call that the function makes:</p> <pre><code>url &lt;- "https://stream.twitter.com/1.1/statuses/filter.json" output &lt;- tryCatch(oauth$OAuthRequest(URL = url, params = params, method = "POST", customHeader = NULL, writefunction = topicWrite, cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")), error = function(e) e) </code></pre> <p>I tried removing the timeout component but it doesn't seem to work. Is there a way I can maintain a stream forever (until I kill it) which dumps each tweet as it comes into a topic?</p> <p>P.S. I know of a java implementation that makes a call to the twitter4j API. I, however, have no idea how to do it in R. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload