Exemplo n.º 1
0
 function HTTP_PUT()
 {
     $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();
     $putvars = NULL;
     parse_str(file_get_contents('php://input'), $putvars);
     $phone = isset($putvars["phone"]) ? $putvars["phone"] : NULL;
     $first_name = isset($putvars["first_name"]) ? $putvars["first_name"] : NULL;
     $last_name = isset($putvars["last_name"]) ? $putvars["last_name"] : NULL;
     $email = isset($putvars["email"]) ? $putvars["email"] : NULL;
     $result = $pCore_AddressBook->updateContact($this->_idNumero, $phone, $first_name, $last_name, $email);
     if ($result === FALSE) {
         $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();
     } else {
         $json = new Services_JSON();
         $response["message"] = "The contact was successfully modified";
         return $json->encode($response);
     }
 }