-
Notifications
You must be signed in to change notification settings - Fork 1
/
R_getYouTubeProfilesFromSB.R
37 lines (28 loc) · 1022 Bytes
/
R_getYouTubeProfilesFromSB.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
# R Connector to Social Bakers API
# Function to fetch all registered profiles
# In this function you set variable to fetch a different network from Social Bakers.
## in my case, i only need YouTube.
# Made by Rodrigo Eiras - rsveiras@gmail.com
# 05/09/2017 - Rio de Janeiro / RJ
library(httr)
library(RCurl)
library(jsonlite)
j <- NULL
ids <- NULL
name <- NULL
profileName <- NULL
timezone <- NULL
req <- GET("https://api.socialbakers.com/0/youtube/profiles",
authenticate("login",
"passwd",
type = "basic"),
encode = "json")
stop_for_status(req)
data <- content(req, as = "parsed")
for(j in 1:length(data$profiles)){
ids[j] <- toString(unlist(data$profiles[j][[1]]$id))
name[j] <- toString(unlist(data$profiles[j][[1]]$name))
profileName[j] <- toString(unlist(data$profiles[j][[1]]$profileName))
timezone[j] <- toString(unlist(data$profiles[j][[1]]$timezone))
}
YTprofilesTable <- data.frame(id = ids, name, profileName, timezone)