I'm trying to stream and save public posts through R. I already got the token and made the search. This is what i've done.
require(RCurl)
require(rjson)
data <- getURL("https://graph.facebook.com/search?q=multishow&type=post&access_token=my_token")
That's fine, the "data" character found something. Now, how can I convert this "data" character into a data frame? And is it possible to stream this search during a specific timeout?
Thanks.
UPDATE:
Ok guys, now I can parse the JSON results from Facebook, but I'm still stuck in coverting as data.frame properly and stream to get new posts. Follow code below:
library (RCurl)
library (rjson)
library (plyr)
data <- getURL("https://graph.facebook.com/search?q=my_query&type=post&access_token=my_token, cainfo="cacert.perm")
#JSON parser
parser <- newJSONParser()
parser$addData(data)
fb.data <- parser$getObject()
#JSON to data.frame
#sometimes it works direct from rjson
df <- data.frame(fromJSON(fb.data))
#sometimes it works only with plyr package
df <- do.call("rbind.fill", lapply(fb.data, as.data.frame))
Either way, I get a data.frame with 1 or 2 observations and hundreds of variables. Last search I did, I got my first observaton with 42 variables, second with 13 variables, and so on. Any clue of how can I handle with it?