-
Notifications
You must be signed in to change notification settings - Fork 2
/
feed.go
43 lines (37 loc) · 1.14 KB
/
feed.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 instabot
import (
"context"
"fmt"
"github.com/winterssy/sreq"
)
const (
apiGetUserFeed = apiV1 "feed/user/%s/?max_id=%s"
apiGetTimeline = apiV1 "feed/timeline/"
)
func (bot *Bot) GetUserFeed(ctx context.Context, userId string, maxId string) (sreq.H, error) {
req, _ := sreq.NewRequest(sreq.MethodGet, fmt.Sprintf(apiGetUserFeed, userId, maxId),
sreq.WithContext(ctx),
)
return bot.sendRequest(req)
}
func (bot *Bot) GetSelfFeed(ctx context.Context, maxId string) (sreq.H, error) {
return bot.GetUserFeed(ctx, bot.GetUserId(), maxId)
}
func (bot *Bot) GetTimeline(ctx context.Context, maxId string) (sreq.H, error) {
form := sreq.Form{
"phone_id": bot.phoneId,
"max_id": maxId,
"timezone_offset": bot.timeOffset,
"_csrftoken": bot.GetCSRFToken(),
"device_id": bot.igDeviceId,
"request_id": GenerateUUID(),
"_uuid": bot.uuid,
"session_id": GenerateUUID(),
"bloks_versioning_id": bloksVersionId,
}
req, _ := sreq.NewRequest(sreq.MethodPost, apiGetTimeline,
sreq.WithForm(form),
sreq.WithContext(ctx),
)
return bot.sendRequest(req)
}