Wednesday 15 April 2015

json - Error in twFromJSON(out) - R twitteR package -



json - Error in twFromJSON(out) - R twitteR package -

i have searched extensively online still unable find work-around next error whilst using 'twitter' bundle in r:

"error in twfromjson(out) : error: malformed response server, not json. cause of error twitter returning character can't parsed r. remedy wait long plenty offending character disappear searches (e.g. if using searchtwitter())."

it comes after running next code:

# clear used libraries rm(list=ls()) #set working directory setwd("c:/users/toshiba/google drive/programming/projects/hds/shiny/twitter") #load libraries library (twitter) library (rjsonio) library (dismo) library (maps) library (ggplot2) library (xml) load("twitter_credentials") registertwitteroauth(twitcred) ##############################start app######################################## start_date = '2014-10-10' end_date = tostring(as.date(start_date)+1) #search tweets containing ebola - goes 8 days including today ebolatweets <- searchtwitter("ebola", n = 1250, since=start_date, until=end_date, cainfo="cacert.pem") tweetframe <- twlisttodf(ebolatweets) # convert dataframe

is not possible somehow skip offending tweet instead of breaking loop?

any help much appreciated!

using current version of twitter (1.1.8) on github (which handles authentication much more simply), have no problems.

library(devtools) install_github('twitter', 'geoffjentry') library (twitter) setup_twitter_oauth(consumer_key='blah', consumer_secret='blah', access_token='blah', access_secret='blah') # keys , tokens apps.twitter.com start.date <- '2014-10-10' end.date <- as.character(as.date(start_date) + 1) ebolatweets <- searchtwitter('ebola', 1250, since=start.date, until=end.date) ebola <- twlisttodf(ebolatweets) head(ebola) # text # 1 rt @chillvibessonly: ebola: i'm in broom broom\n\namerica: out me country # 2 rt @rubensancheztw: #alucinante tve usa imágenes de united nations hospital alemán para ilustrar una info sobre el carlos iii http://t.co/5f5okmsjar ht… # 3 rt @danlpda: dejen de hablar del Ébola, me da miedo # 4 realiza republic of colombia estudios 3 viajeros por temor ébola: pese no presentar síntomas del virus los pasajeros... http://t.co/c5ijmgoqki # 5 que es eso del ebola? voy llorar # 6 rt @micamamonde: ebola no te tenemos miedo http://t.co/osglmamfnp # favorited favoritecount replytosn created truncated replytosid id replytouid # 1 false 0 <na> 2014-10-10 23:59:59 false <na> 520725464223326209 <na> # 2 false 0 <na> 2014-10-10 23:59:59 false <na> 520725464185581568 <na> # 3 false 0 <na> 2014-10-10 23:59:59 false <na> 520725463304785921 <na> # 4 false 0 <na> 2014-10-10 23:59:59 false <na> 520725463270821889 <na> # 5 false 1 <na> 2014-10-10 23:59:59 false <na> 520725463120244737 <na> # 6 false 0 <na> 2014-10-10 23:59:59 false <na> 520725463044734976 <na> # statussource screenname retweetcount # 1 <a href="http://twitter.com/download/android" rel="nofollow">twitter android</a> jamesekisses 684 # 2 <a href="http://twitter.com/download/android" rel="nofollow">twitter android</a> patillagrande 2059 # 3 <a href="http://twitter.com" rel="nofollow">twitter web client</a> ariifranciscovi 2 # 4 <a href="http://twitterfeed.com" rel="nofollow">twitterfeed</a> colnros 0 # 5 <a href="http://twitter.com/download/iphone" rel="nofollow">twitter iphone</a> zoevignieri 0 # 6 <a href="http://twitter.com" rel="nofollow">twitter web client</a> felicitasalbano 10 # isretweet retweeted longitude latitude # 1 true false <na> <na> # 2 true false <na> <na> # 3 true false <na> <na> # 4 false false <na> <na> # 5 false false <na> <na> # 6 true false <na> <na>

json r twitter

No comments:

Post a Comment