File tree 1 file changed +16
-0
lines changed 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change 1
1
package anaconda
2
2
3
3
import (
4
+ "io"
5
+ "io/ioutil"
4
6
"net/http"
5
7
"net/url"
8
+ "os"
9
+ "path/filepath"
6
10
"strconv"
11
+ "strings"
7
12
)
8
13
9
14
type OEmbed struct {
@@ -22,12 +27,23 @@ type OEmbed struct {
22
27
23
28
// No authorization on this endpoint. Its the only one.
24
29
func (a TwitterApi ) GetOEmbed (v url.Values ) (o OEmbed , err error ) {
30
+ var f io.Writer
31
+
32
+ filename := filepath .Join (append ([]string {"json" }, strings .Split ("/statuses/oembed.json" , "/" )... )... )
33
+ fl , err := os .OpenFile (filename , os .O_CREATE | os .O_WRONLY , 0644 )
34
+ if err != nil {
35
+ return o , err
36
+ }
37
+ defer fl .Close ()
38
+ f = fl
39
+
25
40
resp , err := http .Get (a .baseUrlV1 () + "/statuses/oembed.json?" + v .Encode ())
26
41
if err != nil {
27
42
return
28
43
}
29
44
defer resp .Body .Close ()
30
45
46
+ resp .Body = ioutil .NopCloser (io .TeeReader (resp .Body , f ))
31
47
err = decodeResponse (resp , & o )
32
48
return
33
49
}
You can’t perform that action at this time.
0 commit comments