Created
August 3, 2010 08:44
-
-
Save tokumine/506062 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# SIMPLE EXAMPLE OF USING PROTECTEDPLANET.NET API TO CHECK PROTECTION STATUS | |
# OF SPECIES LAT/LONG POINTS | |
# S.TOKUMINE & C.MILLS 2010 | |
# | |
# Language: Ruby | |
class MainController < ApplicationController | |
def index | |
base_url = "www.protectedplanet.net" | |
# CONNECT TO GOOGLE SPREADSHEETS | |
session = GoogleSpreadsheet.login(GMAIL_USERNAME, GMAIL_PASSWORD) | |
# GET WORKSHEET, READ DATA, CLEAN AND SORT (ABRIDGED) | |
ws = session.spreadsheet_by_key(GOOGLE_SPREADSHEET_KEY).worksheets[0] | |
rows = ws.rows.dup | |
rows.shift | |
# CHECK PROTECTION WITH PROTECTEDPLANET.NET API | |
rows.each_with_index do |row, i| | |
# CREATE URL | |
url = "http://protectedplanet.net/api/site_atts_by_point/#{row[3]}/#{row[2]}" | |
# **CALL PROTECTEDPLANET API SERVICE AND PARSE RESPONSE** | |
pp = HTTParty.get(url).response.body | |
pas = JSON.parse(pp) | |
# PACKAGE DATA | |
# SEE SOURCE CODE FOR MORE INFORMATION ON THIS STEP | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment