Created
March 4, 2011 02:59
-
-
Save mheadd/854095 to your computer and use it in GitHub Desktop.
An example showing how to use the Node.js library for Open311
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
| var sys = require('sys'); | |
| var Open311 = require('open311').Open311; | |
| var options = { | |
| 'endpoint': 'mayors24.cityofboston.gov', | |
| 'service_path': '/open311/v2/', | |
| 'jurisdiction_id': 'cityofboston.gov', | |
| 'secure': true, | |
| 'port': 6443 | |
| }; | |
| var report = new Open311(options); | |
| report.getServiceList('json'); | |
| report.addListener('responseCode', function(code) { | |
| sys.puts('Response code: ' + code); | |
| sys.puts(''); | |
| }); | |
| report.addListener('responseBody', function(body) { | |
| var service_list = JSON.parse(body); | |
| for(var i = 0; i < service_list.services.length; i++) { | |
| sys.puts('Service Name: ' + service_list.services[i].service_name); | |
| sys.puts('Service Code: ' + service_list.services[i].service_code); | |
| sys.puts(''); | |
| } | |
| }); |
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
| Response code: 200 | |
| Service Name: Other | |
| Service Code: miscellaneous-report | |
| Service Name: Graffiti | |
| Service Code: graffiti-report | |
| Service Name: Pothole | |
| Service Code: pothole-report | |
| Service Name: Streetlight | |
| Service Code: broken-streetlight-report | |
| Service Name: Roadway Plowing/Sanding | |
| Service Code: snow-plow-report | |
| Service Name: Unshoveled Sidewalk | |
| Service Code: unshoveled-sidewalk-report |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment