forked from ChimeraCoder/anaconda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
oembed.go
49 lines (43 loc) · 1.01 KB
/
oembed.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
package anaconda
import (
"net/http"
"net/url"
"strconv"
)
type OEmbed struct {
Type string
Width int
Cache_age string
Height int
Author_url string
Html string
Version string
Provider_name string
Provider_url string
Url string
Author_name string
}
// No authorization on this endpoint. Its the only one.
func (a TwitterApi) GetOEmbed(v url.Values) (o OEmbed, err error) {
resp, err := http.Get(BaseUrlV1 + "/statuses/oembed.json?" + v.Encode())
if err != nil {
return
}
defer resp.Body.Close()
err = decodeResponse(resp, &o)
return
}
// Calls GetOEmbed with the corresponding id. Convenience wrapper for GetOEmbed()
func (a TwitterApi) GetOEmbedId(id int64, v url.Values) (o OEmbed, err error) {
if v == nil {
v = url.Values{}
}
v.Set("id", strconv.FormatInt(id, 10))
resp, err := http.Get(BaseUrlV1 + "/statuses/oembed.json?" + v.Encode())
if err != nil {
return
}
defer resp.Body.Close()
err = decodeResponse(resp, &o)
return
}