Files
uni-ba-socialagenda/.Rhistory
T

73 lines
2.4 KiB
R
Raw Normal View History

2014-12-01 17:41:33 +01:00
source("functions.R")
setwd("~/Dokumente/Uni/Aktuell/BA-Arbeit/uni-ba-issuecomp")
require(jsonlite)
require(stringr)
require(RCurl)
require(devtools)
require(RTwitterAPI)
source("functions.R")
setwd("~/Dokumente/Uni/Aktuell/BA-Arbeit/uni-ba-issuecomp")
2014-11-30 03:41:23 +01:00
api_params <- c(
2014-11-29 21:41:28 +01:00
"oauth_consumer_key" = "c9Ob2fWNSONMC0mA2JlNaeRke",
"oauth_nonce" = NA,
"oauth_signature_method" = "HMAC-SHA1",
"oauth_timestamp" = NA,
"oauth_token" = "1007025684-RFxCDFc4OPkt02bASmdci00TB4jgaPjfqxLRT58",
"oauth_version" = "1.0",
"consumer_secret" = "cZ3Il2hmbLgK0Lc57mj5kUvymjVdsmZKYwKOGHR3NhCpvWgEOI",
"oauth_token_secret" = "rvfv8MgexFKTqrPNSoGrdrZVNhV4fTJb2Bgz249nbvKNg"
2014-11-30 03:41:23 +01:00
)
api_url <- "https://api.twitter.com/1.1/statuses/user_timeline.json";
2014-12-01 17:41:33 +01:00
# api_url <- "https://api.twitter.com/1.1/statuses/show.json";
2014-11-30 03:41:23 +01:00
user <- "peteraltmaier"
max_count <- "200"
max_id <- "999999999999999999"
loop <- 1
keep <- c("created_at", "id_str", "text", "retweet_count")
rm(tweets_full, tweets_temp)
repeat {
query <- c(include_rts=1, exclude_replies="true", trim_user="true", include_entities="false",
screen_name=user,
count=max_count,
max_id=max_id);
2014-12-01 17:41:33 +01:00
# query <- c(trim_user="true", include_entities="false",
# id="431858659656990721");
2014-11-30 03:41:23 +01:00
if(exists("tweets_full")) {
current <- twitter_api_call(api_url, query, api_params)
2014-12-01 17:41:33 +01:00
tweets_temp <- fromJSON(current)
2014-11-30 03:41:23 +01:00
tweets_temp <- tweets_temp[keep]
tweets_full <- insertRow(tweets_full, tweets_temp)
}
else {
current <- twitter_api_call(api_url, query, api_params)
tweets_full <- fromJSON(correctJSON(current))
tweets_full <- tweets_full[keep]
}
status <- str_detect(tweets_full$created_at[nrow(tweets_full)], "2013$")
if (status) {
rm(tweets_temp)
for(r in 1:nrow(tweets_full)) {
status <- str_detect(tweets_full$created_at[r], "2013$")
if(is.na(status)) { status <- FALSE }
if(status) {
tweets_full <- tweets_full[-r,]
}
}
break
}
else {
max_id <- as.character(as.numeric(tweets_full$id_str[nrow(tweets_full)]) - 1)
loop <- loop + 1
}
}
current <- twitter_api_call(api_url, query, api_params)
2014-12-01 17:41:33 +01:00
tweets_temp <- fromJSON(current)
2014-11-30 03:41:23 +01:00
tweets_temp <- fromJSON(correctJSON(current))
current
current
2014-12-01 17:41:33 +01:00
rm(tweets_full, api_params, api_url, keep, loop, max_count, max_id, status, user, insertRow, correctJSON2)
query
2014-11-30 03:41:23 +01:00
api_url <- "https://api.twitter.com/1.1/statuses/user_timeline.json";
2014-12-01 17:41:33 +01:00
save.image("~/Dokumente/Uni/Aktuell/BA-Arbeit/uni-ba-issuecomp/RData.RData")
load("/home/max/Dokumente/Uni/Aktuell/BA-Arbeit/uni-ba-issuecomp/RData.RData")