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

Function GetPostLikes

bluesky/blueskyapi.go:1460–1488  ·  view source on GitHub ↗
(pds string, token string, uri string, limit int)

Source from the content-addressed store, hash-verified

1458}
1459
1460func GetPostLikes(pds string, token string, uri string, limit int) (*Likes, error) {
1461 url := fmt.Sprintf(pds+"/xrpc/app.bsky.feed.getLikes?limit=%d&uri=%s", limit, uri)
1462
1463 resp, err := SendRequest(&token, http.MethodGet, url, nil)
1464 if err != nil {
1465 return nil, err
1466 }
1467 defer resp.Body.Close()
1468
1469 // // Print the response body
1470 // bodyBytes, _ := io.ReadAll(resp.Body)
1471 // bodyString := string(bodyBytes)
1472 // fmt.Println("Response Body:", bodyString)
1473
1474 if resp.StatusCode != http.StatusOK {
1475 bodyBytes, _ := io.ReadAll(resp.Body)
1476 bodyString := string(bodyBytes)
1477 fmt.Println("Response Status:", resp.StatusCode)
1478 fmt.Println("Response Body:", bodyString)
1479 return nil, errors.New(bodyString) // return response
1480 }
1481
1482 likes := Likes{}
1483 if err := json.NewDecoder(resp.Body).Decode(&likes); err != nil {
1484 return nil, err
1485 }
1486
1487 return &likes, nil
1488}
1489
1490// https://docs.bsky.app/docs/api/app-bsky-feed-get-actor-likes
1491// Bluesky for SOME REASON limits viewing the likes to your own user. WHy?

Callers

nothing calls this directly

Calls 1

SendRequestFunction · 0.85

Tested by

no test coverage detected