I use RSS feeds to keep up to date with things ranging from blog articles, to upcoming events, to simple comic strips. However RSS feeds have fallen out of favor in recent years, and sites like Facebook and Instagram are opting not to provide RSS feeds since it goes counter to their business goals. RSSer generates RSS feeds for these sites.
RSSer is open sourced on GitHub. At the time of writing RSSer can generate feeds for Instagram. More generators may be added as I need them, though contributions would certainly be welcome!
Here’s a simple server that provides RSS feeds for Instagram users. Highlighted
is the main API exposed by the github.com/benjaminheng/rsser/instagram
package.
package main
import (
"context"
"log"
"net/http"
"github.com/benjaminheng/rsser/instagram"
"github.com/gorilla/mux"
)
func main() {
r := mux.NewRouter()
r.HandleFunc("/feed/instagram/user/{username}", InstagramFeedHandler)
log.Println("Server listening on :8000")
log.Fatal(http.ListenAndServe(":8000", r))
}
func InstagramFeedHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
username := vars["username"]
feed, err := instagram.GetUserFeed(context.Background(), username)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
return
}
rss, err := feed.ToRss()
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
w.Write([]byte(err.Error()))
return
}
w.WriteHeader(http.StatusOK)
w.Write([]byte(rss))
}