-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.go
45 lines (40 loc) · 975 Bytes
/
user.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
package fblib
import (
"errors"
"net/url"
)
var (
UserNotConnectedError = errors.New("User Not Connected")
)
// Useful if all you want is to have an Id to perform actions
// This prevents having to query a user object from FB.
func NewUser(Id string, fc *FacebookClient) *User {
return &User{Id: Id, Client: fc}
}
func (user *User) PostStatus(message string) error {
if user.Client == nil {
return UserNotConnectedError
}
if message == "" {
return errors.New("Missing message parameter")
}
u := make(url.Values)
u.Set("message", message)
_, err := user.Client.Call("POST", user.Id+"/feed", u)
return err
}
func (user *User) PostLink(link, message string) error {
if user.Client == nil {
return UserNotConnectedError
}
if link == "" {
return errors.New("Missing link parameter")
}
u := make(url.Values)
if message != "" {
u.Set("message", message)
}
u.Set("link", link)
_, err := user.Client.Call("POST", user.Id+"/links", u)
return err
}