-
Notifications
You must be signed in to change notification settings - Fork 0
/
authenticate.R
51 lines (37 loc) · 1.96 KB
/
authenticate.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
'
Script : Authentication
Created : November 21, 2014
Author(s) : iHub Research
Version : v1.0
License : Apache License, Version 2.0
'
# Register app at https://apps.twitter.com to get authentication credentials
#========================= Twitter App Authentication ===================================================================================
# Load Required library
library(twitteR)
library(ROAuth)
#========================= Set Working Directory ========================================================================================
# Set Directory for All Files
setwd('C:/Users/hp/Documents/GitHub/UmatiCodebase/Collection/Twitter')
#======================== App Credentials ===============================================================================================
# Add App Keys Provided by Twitter
consumerKey = '8mzRs9PySHKmTcvXBcy5w'
consumerSecret = 'ZKNBKniG4ADfyk3tHCWQsj0wowapFpXhqoj8O4OnQQ'
# Setup Twitter App Credentials
reqURL <-"https://api.twitter.com/oauth/request_token"
accessURL <-"https://api.twitter.com/oauth/access_token"
authURL <-"https://api.twitter.com/oauth/authorize"
consKey <- consumerKey
consSecret <- consumerSecret
#======================= Authenticate ===================================================================================================
# Authenticate Credentials
twitCred <- OAuthFactory$new(consumerKey=consKey,consumerSecret=consSecret,requestURL=reqURL,accessURL=accessURL,authURL=authURL)
# Download Authentication Certificate
download.file(url="http://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem")
# Initiate System Handshake
twitCred$handshake(cainfo="cacert.pem")
# Set SSL Certs
options(RCurlOptions = list(cainfo = system.file("CurlSSL", "cacert.pem", package = "RCurl")))
# Save Authentication Credentials
save(list="twitCred", file="twitteR_credentials")
#==========================================================================================================================================