forked from ahmdrz/goinsta
-
Notifications
You must be signed in to change notification settings - Fork 0
/
location.go
63 lines (56 loc) · 1.53 KB
/
location.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package goinsta
import (
"encoding/json"
"fmt"
)
type LocationInstance struct {
inst *Instagram
}
func newLocation(inst *Instagram) *LocationInstance {
return &LocationInstance{inst: inst}
}
type LayoutSection struct {
LayoutType string `json:"layout_type"`
LayoutContent struct {
Medias []struct {
Media Item `json:"media"`
} `json:"medias"`
} `json:"layout_content"`
FeedType string `json:"feed_type"`
ExploreItemInfo struct {
NumColumns int `json:"num_columns"`
TotalNumColumns int `json:"total_num_columns"`
AspectRatio int `json:"aspect_ratio"`
Autoplay bool `json:"autoplay"`
} `json:"explore_item_info"`
}
type Section struct {
Sections []LayoutSection `json:"sections"`
MoreAvailable bool `json:"more_available"`
NextPage int `json:"next_page"`
NextMediaIds []int64 `json:"next_media_ids"`
NextMaxID string `json:"next_max_id"`
Status string `json:"status"`
}
func (l *LocationInstance) Feeds(locationID int64) (*Section, error) {
// TODO: use pagination for location feeds.
insta := l.inst
body, err := insta.sendRequest(
&reqOptions{
Endpoint: fmt.Sprintf(urlFeedLocations, locationID),
Query: map[string]string{
"rank_token": insta.rankToken,
"ranked_content": "true",
"_csrftoken": insta.token,
"_uuid": insta.uuid,
},
IsPost: true,
},
)
if err != nil {
return nil, err
}
section := &Section{}
err = json.Unmarshal(body, section)
return section, err
}