function HTTP_POST() { $json = new paloSantoJSON(); if (!isset($_SERVER['CONTENT_TYPE']) || $_SERVER['CONTENT_TYPE'] != 'application/x-www-form-urlencoded') { header('HTTP/1.1 415 Unsupported Media Type'); $json->set_status("ERROR"); $json->set_error('Please POST standard URL encoding only'); return $json->createJSON(); } $pCore_AddressBook = new core_AddressBook(); $first_name = isset($_POST["first_name"]) ? $_POST["first_name"] : NULL; $last_name = isset($_POST["last_name"]) ? $_POST["last_name"] : NULL; $work_phone = isset($_POST["phone"]) ? $_POST["phone"] : NULL; $cell_phone = isset($_POST["cell_phone"]) ? $_POST["cell_phone"] : NULL; $home_phone = isset($_POST["home_phone"]) ? $_POST["home_phone"] : NULL; $fax1 = isset($_POST["fax1"]) ? $_POST["fax1"] : NULL; $fax2 = isset($_POST["fax2"]) ? $_POST["fax2"] : NULL; $email = isset($_POST["email"]) ? $_POST["email"] : NULL; $province = isset($_POST["province"]) ? $_POST["province"] : NULL; $city = isset($_POST["city"]) ? $_POST["city"] : NULL; $address = isset($_POST["address"]) ? $_POST["address"] : NULL; $company = isset($_POST["company"]) ? $_POST["company"] : NULL; $company_contact = isset($_POST["company_contact"]) ? $_POST["company_contact"] : NULL; $contact_rol = isset($_POST["contact_rol"]) ? $_POST["contact_rol"] : NULL; $picture = isset($_POST["picture"]) ? $_POST["picture"] : NULL; $notes = isset($_POST["notes"]) ? $_POST["notes"] : NULL; $status = isset($_POST["status"]) ? $_POST["status"] : NULL; $result = $pCore_AddressBook->addAddressBookContact($work_phone, $first_name, $last_name, $email, TRUE, $address, $company, $notes, $status, $cell_phone, $home_phone, $fax1, $fax2, $province, $city, $company_contact, $contact_rol, $picture); if ($result !== FALSE) { Header('HTTP/1.1 201 Created'); Header('Location: /rest.php/address_book/ContactList/' . $this->_addressBookType . "/{$result}"); } else { $error = $pCore_AddressBook->getError(); if ($error["fc"] == "DBERROR") { header("HTTP/1.1 500 Internal Server Error"); } else { header("HTTP/1.1 400 Bad Request"); } $json->set_status("ERROR"); $json->set_error($error); return $json->createJSON(); } }
function HTTP_POST() { $json = new paloSantoJSON(); if (!isset($_SERVER['CONTENT_TYPE']) || $_SERVER['CONTENT_TYPE'] != 'application/x-www-form-urlencoded') { header('HTTP/1.1 415 Unsupported Media Type'); $json->set_status("ERROR"); $json->set_error('Please POST standard URL encoding only'); return $json->createJSON(); } $pCore_AddressBook = new core_AddressBook(); $phone = isset($_POST["phone"]) ? $_POST["phone"] : NULL; $first_name = isset($_POST["first_name"]) ? $_POST["first_name"] : NULL; $last_name = isset($_POST["last_name"]) ? $_POST["last_name"] : NULL; $email = isset($_POST["email"]) ? $_POST["email"] : NULL; $result = $pCore_AddressBook->addAddressBookContact($phone, $first_name, $last_name, $email, TRUE); if ($result !== FALSE) { Header('HTTP/1.1 201 Created'); Header('Location: ' . $this->requestURL() . "/{$result}"); } else { $error = $pCore_AddressBook->getError(); if ($error["fc"] == "DBERROR") { header("HTTP/1.1 500 Internal Server Error"); } else { header("HTTP/1.1 400 Bad Request"); } $json->set_status("ERROR"); $json->set_error($error); return $json->createJSON(); } }
/** * Function that implements the SOAP call to add a new contact to the external address book. If an error exists a SOAP fault is * thrown * * @param mixed $request: * phone: phone number of new contact * first_name: First Name of the contact * last_name: Last Name of the contact * email: Email of the contact * @return mixed Array with boolean data, true if was successful or false if an error exists */ public function addAddressBookContact($request) { $return = parent::addAddressBookContact($request->phone, $request->first_name, $request->last_name, $request->email); if (!$return) { $eMSG = parent::getError(); $this->objSOAPServer->fault($eMSG['fc'], $eMSG['fm'], $eMSG['cn'], $eMSG['fd'], 'fault'); } return array("return" => $return); }