-
-
Notifications
You must be signed in to change notification settings - Fork 388
/
app.R
35 lines (29 loc) · 894 Bytes
/
app.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
# Dean Attali, July 2015
library(shiny)
ui <- fluidPage(
tags$head(
includeScript("www/api.js"),
includeScript("www/app.js")
),
actionButton("fbLoginBtn", "Login with Facebook"),
div(id = "fbStatus")
)
server <- function(input, output, session) {
source("api.R", local = TRUE)$value
api.fblogin <- function(params) {
fbGraphUrl <- "https://graph.facebook.com"
fbGraphPath <- "me"
token <- params$access_token
url <- sprintf("%s/%s", fbGraphUrl, fbGraphPath)
response <- httr::GET(url, query = list(access_token = token))
if (httr::status_code(response) == 200) {
name <- httr::content(response)$name
cat(name)
# now we can register the user in our database and process them
return(list(success = TRUE, name = name))
} else {
stop("OpenGraph did not succeed")
}
}
}
shinyApp(ui = ui, server = server)