}
 if (isset($_REQUEST['selected_address'])) {
     $address_string = $_REQUEST['selected_address'];
     $lat = '';
     $lon = '';
 }
 if (isset($_REQUEST['selected_service'])) {
     $service_code = $_REQUEST['selected_service'];
 }
 if (isset($_REQUEST['selected_lat'])) {
     $lat = $_REQUEST['selected_lat'];
     $lon = $_REQUEST['selected_lon'];
 }
 // 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->errorCode) > 0) {
     throw new create_requestException("API Error message returned: " . $createRequestXML->open311_error->errorDescription);
 }
 $email_to_me = "Email tracking information!";
 $status_url = BASE_STATUS_URL . "?ref=" . $createRequestXML->request->service_request_id;
 if ($customer_email != "") {
     $status_url .= "&email=" . $customer_email;
 }
 echo ' <script language="Javascript"> var output_array = new Array();';
 echo 'output_array[0]="' . $createRequestXML->request->service_request_id . '";' . "\n";
 echo 'output_array[1]="' . $_REQUEST['selected_service_name'] . '";' . "\n";
 echo 'output_array[2]="' . $address_string . '";' . "\n";
 echo 'output_array[3]="' . str_replace("\n", " ", htmlentities($description)) . '";' . "\n";
 echo 'output_array[4]="' . htmlentities($media_url) . '";' . "\n";
示例#2
0
   COPYING for details.
****/
/**
* Usage example: Get a list of 311 services.
*/
// Include the Open 311 classes.
include_once 'classes/sf311.php';
define("SERVICELIST_URL", "");
define("API_KEY", "");
define("CITY_ID", "");
try {
    // Create a new instance of the Open 311 class.
    $open311 = new sf311(SERVICELIST_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.
    // Construct an array for later use
    foreach ($serviceTypesXML->service as $service) {
        //echo $service->service_code.": ".$service->service_name.": ".$service->description."<br />";
        array_push($service_list, $service);
    }
} catch (service_listException $ex) {
    //die("ERROR: ".$ex->getMessage());
} catch (Exception $ex) {
    //die("Sorry, a problem occured: ".$ex->getMessage());
}