-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path03-requirements.Rmd
71 lines (50 loc) · 2.52 KB
/
03-requirements.Rmd
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
# Prerequisites {#prerequisites}
In this chapter we get you set up and running with the _twinetverse_, namely installing the packages and setting up rtweet to fetch tweets.
## Install
The package is available from [Github](https://github.com/JohnCoene/twinetverse) can be installed with devtools [@R-devtools] or remotes [@R-remotes]. First install the remotes package with:
```{r eval=FALSE}
install.packages("remotes")
```
Then install the twinetverse with:
```{r eval=FALSE}
remotes::install_github("JohnCoene/twinetverse")
```
```{block, type="note"}
In the book we don't explicitly load the package and assume you have it loaded in your environment (snippet below).
```
```{r eval=FALSE}
library(twinetverse)
```
## Setup rtweet
The rtweet package requires some set up. This is not only extremely easy but also very well explained on rtweet's [official website](http://rtweet.info/articles/auth.html), so head over there if the short description below does not satisfy.
In essence, you will need a Twitter "app" to access its API, to create one:
1. Head over to [apps.twitter.com](https://apps.twitter.com/) and login or signup if you do not have a Twitter account.
2. Click create an app.
3. In the following form, enter an app name, whatever you want, this does not matter.
4. Enter a description, then again, it doesn't matter.
5. Under website, simply put a valid website, you can link to your Twitter profile if you do not have one, i.e.: [https://twitter.com/jdatap](https://twitter.com/jdatap)
6. Callback URL, this is **important**, in there put the following: `http://127.0.0.1:1410`, **exactly as is**.
You're now setup with an app, take note of the crendentials of your app under "Keys and Access Tokens", as you will need it to create your token and fetch tweets:
* Consumer Key (`consumer_key`)
* Consumer Secret (`consumer_secret`)
* Access Token (`access_token`)
* Access Token Secret (`access_secret`)
```{block, type = "warn"}
Do **NOT** share those credentials or your token with anyone.
```
Create your token with like so.
```{r, eval=FALSE}
library(twinetverse)
TK <- create_token(
"My Application Name",
consumer_key = "XxxxXxXXxXx",
consumer_secret = "XxxxXxXXxXx",
access_token = "XxxxXxXXxXx",
access_secret = "XxxxXxXXxXx"
)
```
Ideally, also save it. There is no need to re-create a token everytime you want to download data. Once saved you can easily load it `readRDS` (we'll demonstrate that in the next chapter).
```{r, eval = FALSE}
saveRDS(TK, file = "token.rds")
```
You're now all set to build Twitter networks!