-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestScript.R
82 lines (69 loc) · 2.21 KB
/
testScript.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
source("auth.R")
library(rlist)
library(pipeR)
library(jsonlite)
# repos <- "https://api.github.com/users/jiplaolm/repos?per_page=100&page=%d" %>>%
# sprintf(1:2) %>>%
# list.load("json") %>>%
# list.ungroup
#
# repos
#
#
# org <- "https://api.github.com/orgs/EHUGasteiz/members" %>>%
# sprintf(1:2) %>>%
# list.load("json") %>>%
# list.ungroup
#
# org
library(httr)
# 1. Find OAuth settings for github:
# http://developer.github.com/v3/oauth/
oauth_endpoints("github")
# 2. To make your own application, register at at
# https://github.com/settings/applications. Use any URL for the homepage URL
# (http://github.com is fine) and http://localhost:1410 as the callback url
#
# Replace your key and secret below.
myapp <- oauth_app("RepositoryInfoAnalysis",
key = "c9250479230abb9a683b",
secret = "089e1fed7f06fe76eae15bc879b4222eb40fd2d0")
# 3. Get OAuth credentials
github_token <- oauth2.0_token(oauth_endpoints("github"), myapp)
# 4. Use API
gtoken <- config(token = github_token)
req <- GET("https://api.github.com/orgs/EHUGasteiz/members", gtoken)
stop_for_status(req)
content(req)
## Tokenaren bidez informazioa lortu ahal izateko
token <- paste("token", github_app_token)
req <- GET("https://api.github.com/orgs/EHUGasteiz/members",
add_headers(Authorization= token))
stop_for_status(req)
answer <- content(req)
info <- fromJSON(content(req,"text"))
info
## Events
event_req <- GET("https://api.github.com/users/jiplaolm/events",
add_headers(Authorization= token))
stop_for_status(event_req)
answer <- content(event_req, "text")
event_info <- fromJSON(answer)
head(event_info)
## Commits
event_req <- GET("https://api.github.com/repos/jiplaolm/RepositoryInfoAnalysis/commits?per_page=100",
add_headers(Authorization= token))
stop_for_status(event_req)
answer <- content(event_req, "text")
event_info <- fromJSON(answer)
head(event_info)
#
#
#
# # Repository events
# event_req <- GET("https://api.github.com/repos/jiplaolm/RepositoryInfoAnalysis/events",
# add_headers(Authorization= token))
# stop_for_status(event_req)
# answer <- content(event_req, "text")
# event_info <- fromJSON(answer)
# head(event_info)