문제

I am trying to parse a webcal link

webcal://www.facebook.com/ical/b.php?uid=13301632&key=asdgagaweg

in a Ruby on Rails app so I can customize the event entries. I have looked into both RiCal and icalendar but neither show any support for reading a calendar feed (webcal://).

Are there any Rails libraries that support parsing webcal addresses? If not, how should I go about creating my own parser?

도움이 되었습니까?

해결책

webcal is just an unofficial URI scheme for accessing icalendar documents. You can get the calendar using http and parse it using one of several icalendar plugins:

require 'net/http'
uri = URI('http://www.facebook.com/ical/b.php?uid=13301632&key=asdgagaweg')
calendar = Net::HTTP.get(uri)

For alternative ways to perform the http get request: How make a HTTP request using Ruby on Rails?

Then parse the response using your favourite plug-in:

icalendar:

cal = icalendar.parse(calendar).first

vPim:

cal = Vpim::Icalendar.decode(calendar).first  

ri_cal:

cal = RiCal.parse_string(calendar).first
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top