@@ -717,6 +717,39 @@ func GetUserTimeline(pds string, token string, context string, actor string, lim
717717 return nil , & feeds
718718}
719719
720+ func GetMediaTimeline (pds string , token string , context string , actor string , limit int ) (error , * Timeline ) {
721+ apiURL := pds + "/xrpc/app.bsky.feed.getAuthorFeed?actor=" + url .QueryEscape (actor ) + "&limit=" + fmt .Sprintf ("%d" , limit ) + "&filter=posts_with_media"
722+ if context != "" {
723+ apiURL = pds + "/xrpc/app.bsky.feed.getAuthorFeed?actor=" + url .QueryEscape (actor ) + "&cursor=" + context + "&limit=" + fmt .Sprintf ("%d" , limit ) + "&filter=posts_with_media"
724+ }
725+
726+ resp , err := SendRequest (& token , http .MethodGet , apiURL , nil )
727+ if err != nil {
728+ return err , nil
729+ }
730+ defer resp .Body .Close ()
731+
732+ // // Print the response body for debugging
733+ // bodyBytes, _ := io.ReadAll(resp.Body)
734+ // bodyString := string(bodyBytes)
735+ // fmt.Println("Response Body:", bodyString)
736+
737+ if resp .StatusCode != http .StatusOK {
738+ bodyBytes , _ := io .ReadAll (resp .Body )
739+ bodyString := string (bodyBytes )
740+ fmt .Println ("Response Status:" , resp .StatusCode )
741+ fmt .Println ("Response Body:" , bodyString )
742+ return errors .New ("failed to fetch timeline" ), nil
743+ }
744+
745+ feeds := Timeline {}
746+ if err := json .NewDecoder (resp .Body ).Decode (& feeds ); err != nil {
747+ return err , nil
748+ }
749+
750+ return nil , & feeds
751+ }
752+
720753func GetPost (pds string , token string , uri string , depth int , parentHeight int ) (error , * ThreadRoot ) {
721754 // Example URL at://did:plc:dqibjxtqfn6hydazpetzr2w4/app.bsky.feed.post/3lchbospvbc2j
722755
0 commit comments