Created
February 10, 2012 03:17
-
-
Save BrianHicks/1786063 to your computer and use it in GitHub Desktop.
Bible.org NET Bible wrapper
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
# Wrapper for bible.org NET Bible API | |
# Use must follow copyright statement at http://bible.org/netbiblecopyright | |
# Code released into the public domain, without warranty | |
http = require 'http' | |
get_passage = (passage, callback) -> | |
passage = encodeURIComponent passage | |
options = | |
host: 'labs.bible.org' | |
port: 80 | |
path: "/api/?passage=" + passage + "&type=json" | |
buffers = [] | |
request = http.get options, (res) -> | |
console.log 'fulfilling request for', options.path | |
res.on 'data', (chunk) -> | |
buffers.push chunk | |
res.on 'end', -> | |
callback JSON.parse buffers.join '' | |
request.on 'error', (error) -> | |
console.log 'problem with request:', error.message |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment