forked from ChimeraCoder/anaconda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlists.go
61 lines (50 loc) · 1.87 KB
/
lists.go
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
package anaconda
import (
"net/url"
"strconv"
)
// CreateList implements /lists/create.json
func (a TwitterApi) CreateList(name, description string, v url.Values) (list List, err error) {
if v == nil {
v = url.Values{}
}
v.Set("name", name)
v.Set("description", description)
response_ch := make(chan response)
a.queryQueue <- query{a.baseUrl + "/lists/create.json", v, &list, _POST, response_ch}
return list, (<-response_ch).err
}
// AddUserToList implements /lists/members/create.json
func (a TwitterApi) AddUserToList(screenName string, listID int64, v url.Values) (users []User, err error) {
if v == nil {
v = url.Values{}
}
v.Set("list_id", strconv.FormatInt(listID, 10))
v.Set("screen_name", screenName)
var addUserToListResponse AddUserToListResponse
response_ch := make(chan response)
a.queryQueue <- query{a.baseUrl + "/lists/members/create.json", v, &addUserToListResponse, _POST, response_ch}
return addUserToListResponse.Users, (<-response_ch).err
}
// GetListsOwnedBy implements /lists/ownerships.json
// screen_name, count, and cursor are all optional values
func (a TwitterApi) GetListsOwnedBy(userID int64, v url.Values) (lists []List, err error) {
if v == nil {
v = url.Values{}
}
v.Set("user_id", strconv.FormatInt(userID, 10))
var listResponse ListResponse
response_ch := make(chan response)
a.queryQueue <- query{a.baseUrl + "/lists/ownerships.json", v, &listResponse, _GET, response_ch}
return listResponse.Lists, (<-response_ch).err
}
func (a TwitterApi) GetListTweets(listID int64, includeRTs bool, v url.Values) (tweets []Tweet, err error) {
if v == nil {
v = url.Values{}
}
v.Set("list_id", strconv.FormatInt(listID, 10))
v.Set("include_rts", strconv.FormatBool(includeRTs))
response_ch := make(chan response)
a.queryQueue <- query{a.baseUrl + "/lists/statuses.json", v, &tweets, _GET, response_ch}
return tweets, (<-response_ch).err
}