i'm getting following error message code intended read instagram posts r. other code reading in first 20 posts, instagram wants request "next_url" additional blocks of posts. looked @ similar answers error, can't find typo in code. did wonder if coming api needs adjusted. i'm new r , hope explained appropriately. appreciate assistance.
error in fromjson(geturl(paste(next_url, token, sep = "")), unexpected.escape = "keep") : unexpected character: p in addition: warning message: in fromjson(geturl(paste(next_url, token, sep = "")), unexpected.escape = "keep") : unexpected escaped character '\ ' @ pos 26. keeping value.
username <- "xxxx" if(grepl(received_profile$username,username)) { user_id <- received_profile$id media <- fromjson(geturl(paste(next_url,token,sep="")),unexpected.escape = "keep") df1 = data.frame(no = 1:length(media$data)) for(i in 1:length(media$data)) { #comments df1$comments[i] <-media$data[[i]]$comments$count #likes: df1$likes[i] <- media$data[[i]]$likes$count #date df1$date[i] <- tostring(as.posixct(as.numeric(media$data[[i]]$created_time), origin="1970-01-01")) } df <- rbind(df, df1) }else { print("error: user not found!") }
i can reproduce problem extending code snippet code extracts next_url
pagination
object in json response returned instagram.
when using rjson::fromjson
parse json response errors like
error in rjson::fromjson(js) : unexpected character:
however, using rjsonio::fromjson
parsing exact same string works fine! string validates correct json online json validators.
this points bug in rjson::fromjson
. may want use rjsonio package instead now.
unfortunately these instagram replies quite large. i'll see if can strip down json output manageable can post details here. (i'm trying avoid having link data on external site.)
i suspect encoding issue instagram user names.
Comments
Post a Comment