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

Function GetPost

bluesky/blueskyapi.go:880–910  ·  view source on GitHub ↗
(pds string, token string, uri string, depth int, parentHeight int)

Source from the content-addressed store, hash-verified

878}
879
880func GetPost(pds string, token string, uri string, depth int, parentHeight int) (*ThreadRoot, error) {
881 // Example URL at://did:plc:dqibjxtqfn6hydazpetzr2w4/app.bsky.feed.post/3lchbospvbc2j
882
883 url := pds + "/xrpc/app.bsky.feed.getPostThread?depth=" + fmt.Sprintf("%d", depth) + "&parentHeight=" + fmt.Sprintf("%d", parentHeight) + "&uri=" + uri
884
885 resp, err := SendRequest(&token, http.MethodGet, url, nil)
886 if err != nil {
887 return nil, err
888 }
889 defer resp.Body.Close()
890
891 // // Print the response body
892 // bodyBytes, _ := io.ReadAll(resp.Body)
893 // bodyString := string(bodyBytes)
894 // fmt.Println("Response Body:", bodyString)
895
896 if resp.StatusCode != http.StatusOK {
897 bodyBytes, _ := io.ReadAll(resp.Body)
898 bodyString := string(bodyBytes)
899 fmt.Println("Response Status:", resp.StatusCode)
900 fmt.Println("Response Body:", bodyString)
901 return nil, errors.New(bodyString) // return response
902 }
903
904 thread := ThreadRoot{}
905 if err := json.NewDecoder(resp.Body).Decode(&thread); err != nil {
906 return nil, err
907 }
908
909 return &thread, nil
910}
911
912// https://docs.bsky.app/docs/api/app-bsky-feed-get-posts
913func GetPosts(pds string, token string, items []string) ([]*Post, error) {

Callers 5

UpdateStatusFunction · 0.85
ReTweetFunction · 0.85
LikePostFunction · 0.85
UnlikePostFunction · 0.85
GetReplyRefsFunction · 0.85

Calls 1

SendRequestFunction · 0.85

Tested by

no test coverage detected