rss_controller.rb 612 B

123456789101112131415161718192021222324252627282930
  1. # Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
  2. class RssController < ApplicationController
  3. before_filter :authentication_check
  4. =begin
  5. Resource:
  6. GET /api/v1/rss_fetch
  7. Response:
  8. {
  9. ...
  10. }
  11. Test:
  12. curl http://localhost/api/v1/rss_fetch.json -v -u #{login}:#{password} -H "Content-Type: application/json" -X GET
  13. =end
  14. def fetch
  15. items = Rss.fetch(params[:url], params[:limit])
  16. if items == nil
  17. render :json => { :message => "failed to fetch #{ params[:url] }", :status => :unprocessable_entity }
  18. return
  19. end
  20. render :json => { :items => items }
  21. end
  22. end