Skip to content

Instantly share code, notes, and snippets.

@mheadd
Created March 4, 2011 02:59
Show Gist options
  • Select an option

  • Save mheadd/854095 to your computer and use it in GitHub Desktop.

Select an option

Save mheadd/854095 to your computer and use it in GitHub Desktop.
An example showing how to use the Node.js library for Open311
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('');
}
});
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