1

Whenever i'm trying to get a post with a lot of comments from Facebook with Rfacebook's getPost-function, i get the following error:

Error in while (n.l < n.likes & length(content$data) > 0 & !is.null(url <- content$paging$`next`)) { : 
  Argument has length 0

The code i'm trying to run looks like this:

post <- getPost(post = "Post-ID", token = token, n = 200)

I've also tried playing around with the different arguments of the function but nothing so far has worked... Anyone has an idea what could have caused this error? Any help is greatly appreciated!

Here's the link to the documentation of the getPost function: https://www.rdocumentation.org/packages/Rfacebook/versions/0.6.15/topics/getPost

L. Lane
  • 43
  • 4

1 Answers1

0

I have a way that attacks your problem from a slightly different angle.

Instead of tackling the post ID you could, extract it from the 'Page' angle, and also this is an easier way of getting the Post ID

Step1: see what 'Page' the post is on then you can extract the 'post' but making sure to use time parameters - for example: "If you want to extract a post form the Nike FB page that has a massive amount of comments - which happened to fall on June, 6th 2016"

nike_posts <- getPage("nike", token = fboauth, n=100000, since = '2016/06/05', until = '2016/06/07')

Step 2: You will then have a data frame of posts - lets say example 7 observations for that time (they possibly post multiple times a day) If the post you are looking for is observation #3, then extract the comments by:

Comments <- getPost(nike_posts$id[3], token = fboauth, n = 10000, comments = TRUE, likes = FALSE, n.likes = 1, n.comments = 100000)

to convert this output to a DataFrame

library(plyr)

Comments <- ldply(Comments, data.frame)

Robert Chestnutt
  • 302
  • 3
  • 13