forked from azer/go-flickr
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.go
More file actions
43 lines (35 loc) · 628 Bytes
/
user.go
File metadata and controls
43 lines (35 loc) · 628 Bytes
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
package flickr
import (
"fmt"
)
type User struct {
Id string
Name string
Title string
IconFarm int
IconServer string
}
type UserRaw struct {
User struct {
Id string
Username map[string]string
Stat string
}
}
func (client *Client) FindUser(name string) (*User, error) {
response, err := client.Request("urls.lookupUser", Params{
"url": fmt.Sprintf("http://flickr.com/photos/%s", name),
})
if err != nil {
return nil, err
}
raw := &UserRaw{}
err = Parse(response, raw)
if err != nil {
return nil, err
}
return &User{
Id: raw.User.Id,
Name: name,
}, nil
}