forked from ahmdrz/goinsta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeline.go
43 lines (38 loc) · 888 Bytes
/
timeline.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
package goinsta
import (
"encoding/json"
)
// Timeline is the object to represent the main feed on instagram, the first page that shows the latest feeds of my following contacts.
type Timeline struct {
inst *Instagram
}
func newTimeline(inst *Instagram) *Timeline {
time := &Timeline{
inst: inst,
}
return time
}
// Get returns latest media from timeline.
//
// For pagination use FeedMedia.Next()
func (time *Timeline) Get() *FeedMedia {
insta := time.inst
media := &FeedMedia{}
media.inst = insta
media.endpoint = urlTimeline
return media
}
// Stories returns slice of StoryMedia
func (time *Timeline) Stories() (*Tray, error) {
body, err := time.inst.sendSimpleRequest(urlStories)
if err == nil {
tray := &Tray{}
err = json.Unmarshal(body, tray)
if err != nil {
return nil, err
}
tray.set(time.inst, urlStories)
return tray, nil
}
return nil, err
}