forked from ChimeraCoder/anaconda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusers.go
56 lines (50 loc) · 1.7 KB
/
users.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
package anaconda
import (
"net/url"
"strconv"
)
func (a TwitterApi) GetUsersLookup(usernames string, v url.Values) (u []User, err error) {
v = cleanValues(v)
v.Set("screen_name", usernames)
response_ch := make(chan response)
a.queryQueue <- query{a.baseUrl + "/users/lookup.json", v, &u, _GET, response_ch}
return u, (<-response_ch).err
}
func (a TwitterApi) GetUsersLookupByIds(ids []int64, v url.Values) (u []User, err error) {
var pids string
for w, i := range ids {
//pids += strconv.Itoa(i)
pids += strconv.FormatInt(i, 10)
if w != len(ids)-1 {
pids += ","
}
}
v = cleanValues(v)
v.Set("user_id", pids)
response_ch := make(chan response)
a.queryQueue <- query{a.baseUrl + "/users/lookup.json", v, &u, _GET, response_ch}
return u, (<-response_ch).err
}
func (a TwitterApi) GetUsersShow(username string, v url.Values) (u User, err error) {
v = cleanValues(v)
v.Set("screen_name", username)
response_ch := make(chan response)
a.queryQueue <- query{a.baseUrl + "/users/show.json", v, &u, _GET, response_ch}
return u, (<-response_ch).err
}
func (a TwitterApi) GetUsersShowById(id int64, v url.Values) (u User, err error) {
v = cleanValues(v)
v.Set("user_id", strconv.FormatInt(id, 10))
response_ch := make(chan response)
a.queryQueue <- query{a.baseUrl + "/users/show.json", v, &u, _GET, response_ch}
return u, (<-response_ch).err
}
func (a TwitterApi) GetUserSearch(searchTerm string, v url.Values) (u []User, err error) {
v = cleanValues(v)
v.Set("q", searchTerm)
// Set other values before calling this method:
// page, count, include_entities
response_ch := make(chan response)
a.queryQueue <- query{a.baseUrl + "/users/search.json", v, &u, _GET, response_ch}
return u, (<-response_ch).err
}