geoffjentry / twitter Goto Github PK
View Code? Open in Web Editor NEWR based twitter client
Home Page: http://cran.r-project.org/web/packages/twitteR/index.html
R based twitter client
Home Page: http://cran.r-project.org/web/packages/twitteR/index.html
Want to have the option to decode shortened URLs
Hi, can the getFollowersIDs (and getFriendsIDs) manage the parameter "cursor" in order to retreive more then 5000 followers?
thanks in advance
Matteo
Can this library manage "cursor" parameter
https://dev.twitter.com/docs/api/1/get/followers/ids
in order to be able to retreive ALL followers?
thanks
matteo
http://www.redaelli.org/matteo/
It would useful (to me at least) if searchTwitter
supported time ranges. For example,
searchTwitter('#rstats', n = 100, since = "2014-05-24 12:54:24 UTC", until = "2014-05-24 23:54:24 UTC")
Hi Jeff:
I am using your TwitterR package (Thank you so much for your work on this!) and comes to a problem.
My PC sits behind a company Proxy and it got issue accessing web throught "https" connections.
Since Twitter API reuqires Oauth now and one of your function in the package "getAPIStr" used an "if else" statement, which if Oauth is TRUE it will use "https" instead of "http".
Is there anyway I can update this function to remove the "if else" statement and force it to use "http" all the time?
While I am on this, is there anyother functions in your package will create "https"?
Cheers!
It would be useful, if this is possible, to handle app-only authentification, because the rate limits are different for user-auth and app-only auth. Twitter actually advises to play with both kinds of authentification to maximise the amout of data one can get.
See https://dev.twitter.com/docs/auth/application-only-auth.
I would find this useful
friendships(user,screen_names = character(), user_ids = character(), ...)
so could look at other people's relationships not just own
I am planning on using it, and hence the question.
I know of many people who have some homebrew mechanism for storing their searches in a database. Provide a standardized mechanism for doing this with a generic backend to support different types of DBs. Initially provide SQLite and MySQL.
Hi Geoff,
Absolutely love the package. I've just started working with R and this package has been a lot of fun.
I'm working on visualizing a friend network using:
following <- seed$getFriends()
following.n <- as.character(lapply(following, function(x) x$getScreenName()))
followed by a loop:
> twitter.data <- list()
> i <- 1
> for (new.user in following.n){
user <- getUser(new.user)
friends <- user$getFriends(retryOnRateLimit=1000)
twitter.data[[i]] <- as.character(lapply(friends, function(x) x$getScreenName()))
}
However, every time i get the error:
Error in split.default(users, ceiling(seq_along(users)/100)) :
first argument must be a vector
Is it an error in the package?
All the best, big fan!
Max
Change over to using Hadley's httr package. This will cut the dependence on ROAuth (and thus my need to maintain it) and hopefully streamline details of the HTTP communication
Hey Geoff,
Im a R novice so excuse my general ignorance. Im trying to get a list of followers for a particular twitter user. The code here is not working for me. Im getting error code "could not find function ffbase". Say Im trying to download a list of Barack Obama's followers. How could I do that?
Also - Is it possible to get a list of geo-located followers?
thanks x 1 mil!!
I am using the twitteR package in R to extract tweets based on their ids. But I am unable to do this for multiple tweet ids without hitting either a rate limit or an error 404. This is because I am using the showStatus() - one tweet id at a time. I am looking for a function similar to getStatuses() - multiple tweet id/request
Is there an efficient way to perform this action. I suppose only 60 requests can be made in a 15 minute window using the outh.
So, how do I ensure :-
1.Retrieve multiple tweet ids for single request thereafter repeating these requests.
2.Rate limit is under check.
3.Error handling for tweets not found.
P.S : This activity is not user based.
Thanks
I complete a successful OAuth handshake, and most functions of twitteR seem to work fine, except publicTimeline():
registerTwitterOAuth(twitCred)
[1] TRUEpublic_tweets = publicTimeline()
Error: Not FoundsessionInfo()
R version 2.15.2 (2012-10-26)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] ROAuth_0.9.2 digest_0.6.2 twitteR_0.99.19 rjson_0.2.12 RCurl_1.95-3 bitops_1.0-4.2
loaded via a namespace (and not attached):
[1] tools_2.15.2
Hi there,
I've been looking for a solution to lower the case of tweets and clean up the data before doing any analysis. Here is a small but useful finding that makes the tolower() function work with no need to do anything else.
I've been using the clean.text function provided here(https://sites.google.com/site/miningtwitter/) quite a bit. But as it normally is, the tolower(x) doesn't always work. I've seen in Jeffrey breen's page a coment regarding this, and i thought of sharing it here. I think it deals well with the lowering-case issue.
The solution is just to add this x = iconv(x, 'UTF-8', 'ASCII') before the tolower() statement. I've added it below already.
Doing it this way, you won't need to use the tryTolower function (you can find this in the same page). It's just changing the enconding before.
I think this is useful for sentiment analysis also, if you can't lower the case of all the words it's hard to get a good result.
Hope you find it useful!
clean.text = function(x)
{
x = iconv(x, 'UTF-8', 'ASCII')
x = tolower(x)
x = gsub("rt", "", x)
x = gsub("@\w+", "", x)
x = gsub("[[:punct:]]", "", x)
x = gsub("http\w+", "", x)
x = gsub("[ |\t]{2,}", "", x)
x = gsub("^ ", "", x)
x = gsub(" $", "", x)
return(x)
}
calls to getFriendIDs() for a list of users kept crashing with error message:
Error in twInterfaceObj$doAPICall(cmd, params, method, ...) :
OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'
crashes happened only at specific user id's.. upon further inspection, these specific users are protected ones (crashes have nothing to do with authentication). An easy workaround is to condition processing of user on protected status.
With retryOnRateLimit > 0 we've a new solution to "get" problems, but it's like doing the same mistake many times. With a "get" request you know the number n of entries requested and (usually) your limit (eg. 800).
IDEA:
Split n in k parts (to have so many n numbers below the limit) and run k "get" requests.
Every new k "get" request starts from latest ID (eg. status, user, follower, friend) AND latest datetime field.
Hello everybody
i have this problem in my code
install.packages(c("devtools", "rjson", "bit64", "httr"))
devtools::install_github("hadley/httr")
library(devtools)
install_github("twitteR", username="geoffjentry")
library(twitteR)
api_key <- "mwcOI7mNkPUhRnnit0Nu75VBO"
api_secret <- "BwyN7OvghbPSW9RDSaSzVu0aRhhH2bKRvQcUucUZQYyxbKSW2u"
access_token <- "2829195264-D8HgRXZCyUd193lC5ILEFsxgGdgIldvBP8zo64E"
access_token_secret <- "2829195264-D8HgRXZCyUd193lC5ILEFsxgGdgIldvBP8zo64E"
setup_twitter_oauth(api_key,api_secret,access_token,access_token_secret)
and i get this error
Error in check_twitter_oauth() : OAuth authentication error:
This most likely means that you have incorrectly called setup_twitter_oauth()'
please can someone help me i reaaly need this problem solve pleasee
I run the authentication steps successfully:
library(ROAuth)
library(twitteR)
reqURL = "https://api.twitter.com/oauth/request_token"
accessURL = "http://api.twitter.com/oauth/access_token"
authURL = "http://api.twitter.com/oauth/authorize"
consumerKey = "Hidden"
consumerSecret = "Hidden"
twitCred <- OAuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,
requestURL=reqURL,
accessURL=accessURL,
authURL=authURL)
twitCred$handshake() ## Authenticate in browser
And then on running homeTimeline() I get this error with this trackback:
> homeTimeline()
Error in function (str) :
promise already under evaluation: recursive default argument reference or earlier problems?
Enter a frame number, or 0 to exit
1: homeTimeline()
2: authStatusBase(n, "home_timeline", maxID = maxID, sinceID = sinceID, ...)
3: statusBase(cmd, params, n, 800, ...)
4: sapply(doPagedAPICall(cmd, n, params, ...), buildStatus)
5: lapply(X = X, FUN = FUN, ...)
6: doPagedAPICall(cmd, n, params, ...)
7: twInterfaceObj$doAPICall(cmd, params, method, ...)
8: APIFunc(url, params, method, ...)
9: oauth$OAuthRequest(url, params, method, ...)
10: httpFunc(URLencode(URL), params = params, consumerKey = .self$consumerKey,
11: getForm(url, .params = params, curl = curl, .opts = .opts, binary = binary)
12: getURLContent(uri, .opts = .opts, .encoding = .encoding, binary = binary, c
13: curlPerform(url = url, curl = curl, .opts = .opts)
14: function (str)
{
if (verbose)
cat("inBody? ", inBody, ", num byt
Selection:
Here's my sessionInfo()
R version 2.15.1 (2012-06-22)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=C LC_COLLATE=C
[5] LC_MONETARY=C LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices datasets utils methods base
other attached packages:
[1] twitteR_0.99.19 rjson_0.2.8 ROAuth_0.92.0 digest_0.5.2
[5] RCurl_1.91-1 bitops_1.0-4.1 knitr_0.6.5 devtools_0.7.1
loaded via a namespace (and not attached):
[1] Rcpp_0.9.10 evaluate_0.4.2 formatR_0.4 httr_0.1.1 memoise_0.1
[6] parser_0.0-14 plyr_1.7.1 stringr_0.6 tools_2.15.1
Any ideas? Thanks!
Hello
I'm using last git version of twitteR package and I'm connecting on Twitter through setup_twitter_oauth() function. When I call the function
setup_twitter_oauth("XXX", "YY", "CCC", "VVXXXX", credentials_file="twitter.cred")
I get:
Error: Deprecated: supply token object to config directly
What's wrong? Older versions (of twitteR and maube other packages) work fine for me...
Thank
Matteo
http://www.redaelli.org/matteo/
user reported seeing the UTF conversion error when setting this flag - is there a logic bug?
From Yanchang ....
Do you have any plan to include the two Twitter APIs below in your package?
I have used them to track the path that a tweet spread over Twitter network,
and it would be very convenient if they are provided in your package.
devtools::install_github("twitteR", username="geoffjentry")
Installing github repo twitteR/master from geoffjentry
Downloading twitteR.zip from https://github.com/geoffjentry/twitteR/archive/master.zip
Installing package from /tmp/RtmpAf0RDJ/twitteR.zip
arguments 'minimized' and 'invisible' are for Windows only
Installing twitteR
Installing dependencies for twitteR:
httr, int64
Installing packages into ‘/home/hadoop/R/x86_64-suse-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
пробую URL 'http://cran.rstudio.com/src/contrib/httr_0.2.tar.gz'
Content type 'application/x-gzip' length 50183 bytes (49 Kb)
открытие URL
downloaded 49 Kb
- installing source package ‘httr’ ...
** пакет ‘httr’ удачно распакован, MD5 sums проверены
** R
** demo
** inst
** preparing package for lazy loading
** help
*** installing help indices
** building package indices
** testing if installed package can be loaded- DONE (httr)
The downloaded source packages are in
‘/tmp/RtmpAf0RDJ/downloaded_packages’
'/usr/lib64/R/bin/R' --vanilla CMD INSTALL
'/tmp/RtmpAf0RDJ/devtoolsf9f5ed1b0a3/twitteR-master'
--library='/home/hadoop/R/x86_64-suse-linux-gnu-library/3.0' --install-tests
ERROR: dependency 'int64' is not available for package 'twitteR'- removing '/home/hadoop/R/x86_64-suse-linux-gnu-library/3.0/twitteR'
Ошибка: Command failed (1)
Вдобавок: Предупреждение
package ‘int64’ is not available (for R version 3.0.2)
showStatus requires a numeric argument, but R doesn't have 64 bit integer.
Therefore, showStatus can't deal with id which is greater than 2^53 correctly.
Currently, status IDs of Twitter are greater than 2^58.
I think showStatus should allow a character argument.
It would useful (to me at least) if searchTwitter
supported time ranges. For example,
searchTwitter('#rstats', n = 100, since = "2014-05-24 12:54:24", until = "2014-05-24 23:54:24")
While trying to use twitteR interactively in R Studio I got this error... "XXXXXX's" are my key and secret respectively.
library(twitteR)
setup_twitter_oauth("XXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX")
[1] "Using browser based authentication"
Use a local file to cache OAuth access credentials between R sessions?
1: Yes
2: No
Selection: 1
Error in init_oauth1.0(endpoint, app, permission = params$permission) :
client error: (401) Unauthorized
I would appreciate any help. I have also seen the same question on stackoverflow but no answer was given. I am running R 3.1.1 with httr 0.5.0.90 and twitteR version 1.1.8.
Thanks,
B
pepsiTweets = userTimeline(pepsi, n=20)
Error in withCallingHandlers(expr, warning = function(w) invokeRestart("muffleWarning")) :
(list) object cannot be coerced to type 'double'
using the function registerTwitterOAuth(Cred)
produces the error:
Error in registerTwitterOAuth(Cred) :
ROAuth is no longer used in favor of httr, please see ?setup_twitter_oauth
but no such documentation exists
blockOnRateLimit need to be TRUE by default everywhere (with network calls), a nice feature that should be renamed for logical reasons. It's not a "block", more a "delayed get (client-side) that will restart in a couple of minutes" :)
One another idea: pass an object with pre-defined (and editable) twitter limits. More than technical issues, to document the existence of these limits and centralize these configurations.
We make a lot of API requests and frequently hit the rate limit. In order to schedule our requests it would be very helpful to always know the number of remaining calls and when the limit resets. Fortunately, the Twitter API returns the remaining calls and the reset time in the header of each reply (x-rate-limit-remaining
, x-rate-limit-reset
).
Do you think that this information could be somehow exposed through twitteR?
If you are generally supportive of such a feature, I'd be happy to provide relevant patches.
Hi, I tried to get tweets excluding replies tweets and I used the following code, but it did not work.
userTimeline(user, n=20, maxID=NULL, sinceID=NULL, excludeReplies=T,includeRts=T,cainfo="cacert.pem")
However, the api 1.1 works well when I use twitter console, like this
https://api.twitter.com/1.1/statuses/user_timeline.json?trim_user=t&exclude_replies=t&include_rts=f&screen_name=...
Package ‘int64’ was removed from the CRAN repository: package ‘int64’ is not available (for R version 3.0.2)
last update at archive 2 years 5 weeks ago, It cannot be used within R 3.02
A new package int64 to support 64-bit integer in R: http://cran.fhcrc.org/web/packages/bit64/
Optional parameter to set value for include_rts
(includeRt which defaults to True) is provided but none exists for similar exclude_replies
API parameter.
If to be implemented should it be excludeReplies or includeReplies in twitteR? They didn't seem to be consistent when they named them and something like excludeReplies=FALSE
is a double negative. Yet keeping to the API has its advantages too.
Example in help page:
status-class {twitteR} R Documentation
Class to contain a Twitter status
Error:
showStatus(id='123')
[1] "missing value where TRUE/FALSE needed"
Error in twInterfaceObj$doAPICall(paste("statuses", "show", id, sep = "/"), :
Error: missing value where TRUE/FALSE needed
setup_twitter_oauth without error, recent id doesn't work either.
Thanks
apologies. namespace issue here.
Hi,
I am getting the following error while trying to run the showStatus function on twitter ID's in order to return the various attributes of the tweet such as text, creation date, user ID etc.
Note: The function runs and returns the desired output for 3-4 ID's before the error shown above pops up and the code stops executing.
What can be done to tackle the issue. I have installed the latest version of the package from github.
Cheers!
It seems that when a status contains some "exotic" (non alphanumeric) character, the twitteR functions may not be able to handle them correctly (at least to the best of my understanding, which remains limited).
An example:
showStatus("439748835238510592")
returns
"AsapVoltaire: RT @CoralieDji: \"Tu penses quoi de Beyoncé ?\" \n\"Je pense que Dieudonné a sa place la dedans\" - @AsapVoltaire \xed\xa0\xbd\xed\xb8\x82\xed\xa0\xbd\xed\xb8\x82\xed\xa0\xbd\xed\xb8\x82"
Is there any way to postprocess this? (by the way I tried the forceUtf8Conversion=TRUE
option, but it throws: Error in tw_from_response(out, ...) : unused argument (forceUtf8Conversion = TRUE)
)
If there's no way to fix this, I think we should at least filter this out, because then it throws errors with further treatments.
Thank you again for the development of the package.
Adding support for profiles photo was nice.
I see that recent versions handle an issue about sinceID; howver I am not able to test as installation from Github laster has a dependancy towards "ROAuth 0.9.4" not available, neither on CRAN nor there.
Eric
Hi,
I simply register my OAuth with:
setup_twitter_oauth(api_key,api_secret,access_token,access_token_secret)
And later I try to update my status via updateStatus('Blah blah blah')
. For the first run I can do this but later for some hours I cannot again do this and receive this message:
Error in twInterfaceObj$doAPICall(endpoint, params = params, method = "POST", :
client error: (403) Forbidden
Can anyone help me?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.