-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfbsearch.go
58 lines (51 loc) · 1.58 KB
/
fbsearch.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
package instabot
import (
"context"
"fmt"
"github.com/winterssy/sreq"
)
const (
apiGetSuggestedSearches = apiV1 + "fbsearch/suggested_searches/?type=%s"
apiGetTopSearches = apiV1 + "fbsearch/topsearch_flat/"
apiGetRecentSearches = apiV1 + "fbsearch/recent_searches/"
apiSearchPlaces = apiV1 + "fbsearch/places/"
)
func (bot *Bot) GetSuggestedSearches(ctx context.Context, _type string) (sreq.H, error) {
req, _ := sreq.NewRequest(sreq.MethodGet, fmt.Sprintf(apiGetSuggestedSearches, _type),
sreq.WithContext(ctx),
)
return bot.sendRequest(req)
}
func (bot *Bot) GetTopSearches(ctx context.Context, query string, count int) (sreq.H, error) {
params := sreq.Params{
"query": query,
"count": count,
"search_surface": "top_search_page",
"timezone_offset": bot.timeOffset,
"context": "blended",
}
req, _ := sreq.NewRequest(sreq.MethodGet, apiGetTopSearches,
sreq.WithQuery(params),
sreq.WithContext(ctx),
)
return bot.sendRequest(req)
}
func (bot *Bot) GetRecentSearches(ctx context.Context) (sreq.H, error) {
req, _ := sreq.NewRequest(sreq.MethodGet, apiGetRecentSearches,
sreq.WithContext(ctx),
)
return bot.sendRequest(req)
}
func (bot *Bot) SearchPlaces(ctx context.Context, query string, count int) (sreq.H, error) {
params := sreq.Params{
"query": query,
"count": count,
"search_surface": "places_search_page",
"timezone_offset": bot.timeOffset,
}
req, _ := sreq.NewRequest(sreq.MethodGet, apiSearchPlaces,
sreq.WithQuery(params),
sreq.WithContext(ctx),
)
return bot.sendRequest(req)
}