Created
March 5, 2011 16:23
-
-
Save hramos/856478 to your computer and use it in GitHub Desktop.
Sample of how to parse superfeedr gowalla checkin objects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.create_with_superfeedr_response(json_response) | |
create! do |checkin| | |
checkin.activity_url = json_response["activity_url"] | |
checkin.user_id = json_response["user_id"] | |
if json_response["object"] | |
spot_hash = Hash.new | |
#spot_hash["image_url"] = ? | |
spot_hash["lat"] = json_response["geo"]["coordinates"][0] | |
spot_hash["lng"] = json_response["geo"]["coordinates"][1] | |
spot_hash["name"] = json_response["object"]["title"] | |
spot_hash["url"] = json_response["object"]["permalinkUrl"] # TODO remove host | |
#spot_hash["city_state"] = ? # which key | |
#spot_hash["description"] = ? # which key | |
spot = Spot.find_by_url(spot_hash["url"]) || Spot.create_with_hash(spot_hash) | |
checkin.spot_id = spot.id | |
end | |
#checkin.message = json_response[""] # no vi un checkin message en superfeedr, use proper key here | |
checkin.checkin_type = "spot" | |
checkin.url = json_response["permalinkUrl"] #parse out host TODO | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment