$service_code = '021';
$lat = '37.76524078';
$lon = '-122.4212043';
$address_string = '123 Some Street, San Francisco, CA 94114';
$address_id = '';
$customer_email = '*****@*****.**';
$device_id = 'se4H173nxaQsddl';
$account_id = '1234567890';
$first_name = 'John';
$last_name = 'Public';
$phone_number = '4151234567';
$description = 'There is a major pothole at this location.';
$media_url = 'http://sf.streetsblog.org/wp-content/uploads/2009/06_18/bike.route.pothole.jpg';
try {
    // Create a new instance of the Open 311 class.
    $open311 = new Open311(BASE_URL, API_KEY, CITY_ID);
    // Create a new 311 Service request.
    $open311->createRequest($service_code, $lat, $lon, $address_string, $address_id, $customer_email, $device_id, $account_id, $first_name, $last_name, $phone_number, $description, $media_url);
    $createRequestXML = new SimpleXMLElement($open311->getOutput());
    // Check to see if an error code and message were returned.
    if (strlen($createRequestXML->open311_error->errorCode) > 0) {
        throw new create_requestException("API Error message returned: " . $createRequestXML->open311_error->errorDescription);
    }
    // Display the ID of the service request.
    //echo "Service Request ID: ".$createRequestXML->service_request->service_request_id;
    echo "Service Request ID: " . $createRequestXML->request->service_request_id;
} catch (create_requestException $ex) {
    die("ERROR: " . $ex->getMessage());
} catch (Exception $ex) {
    die("Sorry, an error occured: " . $ex->getMessage());
}
Exemplo n.º 2
0
/**
 * Useage example: Get a list of 311 service types.
 */

// Include the Open 311 classes.
include('classes/PHPOpen311.php');

define("BASE_URL", "");
define("API_KEY", "");
define("CITY_ID", "");

try {
	
	// Create a new instance of the Open 311 class.
	$open311 = new Open311(BASE_URL, API_KEY, CITY_ID);
	
	// Get a list of service types and descriptions.
	$open311->selectService();
	$serviceTypesXML = new SimpleXMLElement($open311->getOutput());
	
	// Check to see if an error code and message were returned.
	if(strlen($serviceTypesXML->Open311Error->errorCode) > 0) {
		throw new service_listException("API Error message returned: ".$serviceTypesXML->Open311Error->errorDescription);
	}
	
	// Loop through each service type and write out the code, name and description.
	foreach ($serviceTypesXML->Open311ServiceList->service as $service) {
		echo $service['service_code'].": ".$service['service_name'].": ".$service['service_description']."<br />";
	}
	
Exemplo n.º 3
0
 */

// Include the Open 311 classes.
include('classes/PHPOpen311.php');

define("BASE_URL", "");
define("API_KEY", "");
define("CITY_ID", "");

// Service request ID.
$service_request_id = 1122334455;

try {
	
	// Create a new instance of the Open 311 class.
	$open311 = new Open311(BASE_URL, API_KEY, CITY_ID);
	
	// Get a teh current status of a service request.
	$open311->statusUpdate($service_request_id);
	$statusUpdateXML = new SimpleXMLElement($open311->getOutput());
	
	// Check to see if an error code and message were returned.
	if(strlen($statusUpdateXML->Open311Error->errorCode) > 0) {
		throw new status_updateException("API Error message returned: ".$statusUpdateXML->Open311Error->errorDescription);
	}
	
	// Display the current status of the service request.
	echo "Status of Service Request #$service_request_id: ".strtoupper($statusUpdateXML->Open311Status->status);	
}

catch (status_updateException $ex) {
 * Useage example: Create a new 311 service request.
 */

// Include the Open 311 classes.
include('classes/PHPOpen311.php');

define("BASE_URL", "");
define("API_KEY", "");
define("CITY_ID", "");

// Service request information.

try {
	
	// Create a new instance of the Open 311 class.
	$open311 = new Open311(BASE_URL, API_KEY, CITY_ID);
	
	// Create a new 311 Service request.
	// load the api_connection config class to make this call cleaner and more expandable
	// let the createRequest deal with variable assignment from an array
	if(!class_exists('api_connection_settings')) include('classes/api_request_config.php');
	
	$open311->createRequest(api_connection_settings::$_);	
							
	$createRequestXML = new SimpleXMLElement($open311->getOutput());
	
	// Check to see if an error code and message were returned.
	if(strlen($createRequestXML->Open311Error->errorCode) > 0) {
		throw new create_requestException("API Error message returned: ".$createRequestXML->Open311Error->errorDescription);
	}