MCPcopy Index your code
hub / github.com/Preloading/TwitterAPIBridge / GetUserTimeline

Function GetUserTimeline

bluesky/blueskyapi.go:780–811  ·  view source on GitHub ↗

https://docs.bsky.app/docs/api/app-bsky-feed-get-author-feed

(pds string, token string, context string, actor string, limit int)

Source from the content-addressed store, hash-verified

778
779// https://docs.bsky.app/docs/api/app-bsky-feed-get-author-feed
780func GetUserTimeline(pds string, token string, context string, actor string, limit int) (*Timeline, error) {
781 apiURL := pds + "/xrpc/app.bsky.feed.getAuthorFeed?actor=" + url.QueryEscape(actor) + "&limit=" + fmt.Sprintf("%d", limit)
782 if context != "" {
783 apiURL = pds + "/xrpc/app.bsky.feed.getAuthorFeed?actor=" + url.QueryEscape(actor) + "&cursor=" + context + "&limit=" + fmt.Sprintf("%d", limit)
784 }
785
786 resp, err := SendRequest(&token, http.MethodGet, apiURL, nil)
787 if err != nil {
788 return nil, err
789 }
790 defer resp.Body.Close()
791
792 // // Print the response body for debugging
793 // bodyBytes, _ := io.ReadAll(resp.Body)
794 // bodyString := string(bodyBytes)
795 // fmt.Println("Response Body:", bodyString)
796
797 if resp.StatusCode != http.StatusOK {
798 bodyBytes, _ := io.ReadAll(resp.Body)
799 bodyString := string(bodyBytes)
800 fmt.Println("Response Status:", resp.StatusCode)
801 fmt.Println("Response Body:", bodyString)
802 return nil, errors.New(bodyString) // return response
803 }
804
805 feeds := Timeline{}
806 if err := json.NewDecoder(resp.Body).Decode(&feeds); err != nil {
807 return nil, err
808 }
809
810 return &feeds, err
811}
812
813func GetMediaTimeline(pds string, token string, context string, actor string, limit int) (*Timeline, error) {
814 apiURL := pds + "/xrpc/app.bsky.feed.getAuthorFeed?actor=" + url.QueryEscape(actor) + "&limit=" + fmt.Sprintf("%d", limit) + "&filter=posts_with_media"

Callers

nothing calls this directly

Calls 1

SendRequestFunction · 0.85

Tested by

no test coverage detected