MCPcopy Create free account
hub / github.com/Preloading/TwitterAPIBridge / UserSearchAhead

Function UserSearchAhead

bluesky/blueskyapi.go:1587–1614  ·  view source on GitHub ↗

exactly the same as usersearch but different i guess idk

(pds string, token string, query string, limit int)

Source from the content-addressed store, hash-verified

1585
1586// exactly the same as usersearch but different i guess idk
1587func UserSearchAhead(pds string, token string, query string, limit int) ([]User, error) {
1588 url := pds + "/xrpc/app.bsky.actor.searchActorsTypeahead?q=" + url.QueryEscape(query) + "&limit=" + fmt.Sprintf("%d", limit)
1589
1590 resp, err := SendRequest(&token, http.MethodGet, url, nil)
1591 if err != nil {
1592 return nil, err
1593 }
1594 defer resp.Body.Close()
1595
1596 // // Print the response body
1597 // bodyBytes, _ := io.ReadAll(resp.Body)
1598 // bodyString := string(bodyBytes)
1599 // fmt.Println("Response Body:", bodyString)
1600
1601 if resp.StatusCode != http.StatusOK {
1602 bodyBytes, _ := io.ReadAll(resp.Body)
1603 bodyString := string(bodyBytes)
1604 fmt.Println("Response Status:", resp.StatusCode)
1605 fmt.Println("Response Body:", bodyString)
1606 return nil, errors.New(bodyString) // return response
1607 }
1608
1609 users := UserSearchResult{}
1610 if err := json.NewDecoder(resp.Body).Decode(&users); err != nil {
1611 return nil, err
1612 }
1613 return users.Actors, nil
1614}
1615
1616func PostSearch(pds string, token string, query string, since *time.Time, until *time.Time) ([]Post, error) {
1617 url := pds + "/xrpc/app.bsky.feed.searchPosts?sort=top&q=" + url.QueryEscape(query)

Callers

nothing calls this directly

Calls 1

SendRequestFunction · 0.85

Tested by

no test coverage detected