Rfacebook
Rfacebook copied to clipboard
getPage() since value UNIX timestamp is not working
for getPage(page, token, n = 25, since = NULL, until = NULL, feed = FALSE, reactions = FALSE, verbose = TRUE, api = NULL)
If I put a "UNIX timestamp" in to "since". It only accept "date value" not include time value. For Example: if I input timestamp 1512371885. (GMT: 2017-Dec-4 Monday 07:18:05) It only accept value 2017-Dec-4.
Source Code:
if (!is.null(since)){ dates <- formatFbDate(df$created_time, 'date') mindate <- min(dates) sincedate <- as.Date(since) } if (is.null(since)){ sincedate <- as.Date('1970/01/01') mindate <- as.Date(Sys.time()) }
I get the same error:
Error in as.Date.numeric(since): 'origin' must be supplied
What I tried to do is getting posts that are newer than the newest one in a data set ("page_data"):
newest <- as.numeric(lubridate::ymd_hms(max(page_data$created_time)))
Rfacebook::getPage(pagename, token = token, n = n_posts,
reactions = reactions, feed = feed,
since = newest + 1)
And I am pretty sure it worked last week.
Now, when I think about it: it probably did not work last week. I now also got what you were hinting at @yiuking1.
The problem is the code from getPage
you pasted in the initial post (somehow the formatting went away, so I will post it again):
if (!is.null(since)){
dates <- formatFbDate(df$created_time, 'date')
mindate <- min(dates)
sincedate <- as.Date(since)
}
as.Date(...)
needs an origin (afaik 1970-01-01 for UNIX timestamps) when fed with a numeric date. It only works for character vectors in the format "%Y-%m-%d" and "%Y/%m/%d". So, this also does not match the documentation:
A UNIX timestamp or strtotime data value that points to the start of the time range to be searched. For more information on the accepted values, see: http://php.net/manual/en/function.strtotime.php
I think a good and easy solution would be to only accept a certain datetime format and then deal with it accordingly inside the Rfacebook functions.
I've faced with that issue on getPage. Is there a way to solve it without editing the source code? Instead of UNIX timestamp can we feed strtotime data?
Without touching Rfacebook code, only character vectors in the format "%Y-%m-%d" and "%Y/%m/%d" work (AFAIK). So you won't be able to provide the exact time.