-
Notifications
You must be signed in to change notification settings - Fork 128
/
r_rfacebook.r
50 lines (24 loc) · 1.03 KB
/
r_rfacebook.r
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
install.packages("devtools")
library(devtools)
install_github("Rfacebook", "pablobarbera", subdir="Rfacebook")
require("Rfacebook")
######Using the App Authentication:
fb_oauth <- fbOAuth(app_id="123456789", app_secret="1A2B3C4D",extended_permissions = TRUE)
#now we have our fb_oauth connection
#we will just save them to be able to use them later
save(fb_oauth, file="fb_oauth")
#so if you want to connect to Facebook again you just have to call
load("fb_oauth")
me <- getUsers("me",token=fb_oauth)
my_likes <- getLikes(user="me", token=fb_oauth)
######Using the Token Authentication:
token <- 'YOUR AUTHENTICATION TOKEN'
me <- getUsers("me", token, private_info=TRUE)
getUsers(c("barackobama", "donaldtrump"), token)
getFriends(token, simplify = FALSE)
my_friends <- getFriends(token=fb_oauth, simplify=TRUE)
head(my_friends, n=10)
getUser()
my_friends_info <- getUsers(my_friends$id, token=fb_oauth, private_info=TRUE)
#create a table with the relationship statuses
table(my_friends_info$relationship_status)