-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingle_user.go
More file actions
39 lines (36 loc) · 1.02 KB
/
single_user.go
File metadata and controls
39 lines (36 loc) · 1.02 KB
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
package main
import (
"fmt"
"github.com/mrjones/oauth"
"io/ioutil"
"log"
)
const (
ConsumerKey = "<YOUR CONSUMER KEY HERE>"
ConsumerSecret = "<YOUR CONSUMER SECRET HERE>"
AccessToken = "<YOUR ACCESS TOKEN HERE>"
AccessTokenSecret = "<YOUR ACCESS TOKEN SECRET HERE>"
)
func main() {
consumer := oauth.NewConsumer(ConsumerKey,
ConsumerSecret,
oauth.ServiceProvider{})
//NOTE: remove this line or turn off Debug if you don't
//want to see what the headers look like
consumer.Debug(true)
//Roll your own AccessToken struct
accessToken := &oauth.AccessToken{Token: AccessToken,
Secret: AccessTokenSecret}
twitterEndPoint := "https://api.twitter.com/1.1/statuses/mentions_timeline.json"
response, err := consumer.Get(twitterEndPoint, nil, accessToken)
if err != nil {
log.Fatal(err, response)
}
defer response.Body.Close()
fmt.Println("Response:", response.StatusCode, response.Status)
respBody, err := ioutil.ReadAll(response.Body)
if err != nil {
log.Fatal(err)
}
fmt.Println(string(respBody))
}