update_page: Update or get posts from a Facebook page

Description Usage Arguments Value Examples

View source: R/update_pages.R

Description

This function updates one Facebook page with Rfacebook's getPage. It looks for a previously stored data.frame (readable by readRDS, e.g., bbcnews.rds). If there is one, it tries to scrape newer (and older) posts than the ones already stored in the data.frame. Otherwise it creats a new data.frame.

Usage

1
2
update_page(pagename, token, datafile, go_back = TRUE, n_posts = 100,
  feed = FALSE, reactions = FALSE)

Arguments

pagename

A page name.

token

Either a temporary access token created at https://developers.facebook.com/tools/explorer or the OAuth token created with fbOAuth.

datafile

The full path to a RDS data file.

go_back

Go back in time, not only update newer posts, but also get older ones. Default is TRUE.

n_posts

The number of posts to scrape from the page, defaults to 100.

feed

If TRUE, the function will also return posts on the page that were made by others (not only the admin of the page).

reactions

If TRUE, will add variables to the data frame with the total count of reactions: love, haha, wow, sad, angry.

Value

TRUE if it ran through.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# You have to authenticate with Facebook's API first. For more in this visit
# Rfacebooks documentation.
fb_oauth <- fbOAuth(app_id="123456789",
                    app_secret="1A2B3C4D",
                    extended_permissions = TRUE)

# The BBC news page's posts are updated and stored in the user's home
# folder in the directory "temp" as "bbc.rds". If the file does not already
# exist a new file is created
update_page("bbcnews", fb_oauth, "~/temp/bbc.rds")

# The data set can be loaded with readRDS
readRDS("~/temp/bbc.rds")

jogrue/RfacebookHelperFunctions documentation built on Dec. 6, 2017, 12:11 p.m.