Using the code below, I'm saving Meetup events to my database but am unable to save the time due to Meetup's time format.
There are two other StackOverflow questions that cover this, but I got a Syntax Error when trying to implement them. Any suggestions would be greatly appreciated!
Meetup Event Time Format:
- UTC last modified time of the event, in milliseconds since the epoch
- Example of what it looks like in parsed JSON: "time":1413495000000,
- Meetup's API Quickstart Guide: http://www.meetup.com/meetup_api/docs/2/event
Code without converting timestamp:
require 'rubygems'
require 'json'
require 'net/http'
class MeetupController < ApplicationController
respond_to :json
$meetupRI = "http://api.meetup.com/2/open_events?status=upcoming&radius=25.0&category=2&and_text=False&limited_events=False&desc=False&offset=0&photo-host=public&format=json&zip=02903&page=20&sig_id=MYKEY"
def getJobs
if response.code == '200' then
response = Net::HTTP.get_response(URI.parse($meetupRI))
data = response.body
parsed_response = JSON.parse(data)
parsed_response["results"].each do |event|
e = Event.new(:name => event["name"], :description => event["description"], :url => event["event_url"], :start_time => event["time"] )
e.save
end
end
end
end