Last active
December 25, 2015 20:39
-
-
Save szilard/7036195 to your computer and use it in GitHub Desktop.
LA R meetup raffle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(yaml) | |
library(RJSONIO) | |
library(httr) | |
event_id <- 132296372 | |
n_max <- 20 | |
api_key <- yaml.load_file("meetup_api_key.yml")$api_key | |
## get your api key from http://www.meetup.com/meetup_api/key/ while logged in | |
set.seed(123) | |
get_ssl <- function(url) rawToChar(GET(url, config = list(sslversion = 3, ssl.verifyhost = FALSE))$content) | |
## wrap httr::GET with ssl options that work with meetup.com | |
req_url <- paste0("https://www.meetup.com/2/rsvps?key=", api_key, "&event_id=", event_id, "&rsvp=yes") | |
rsvp_data <- fromJSON(get_ssl(req_url)) | |
participants <- sort(sapply(rsvp_data$results, function(x) x$member$name)) | |
data.frame(winners = sample(participants, n_max)) |
This is great. I am a winner! yay. I hope the 14 people before me are not present :P
No book here. I blame seed 123!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
:D