Мой домен указывает на cloudflare, и когда я проверяю API остальных, тогда в домене с https выдает правильный ответ, но с http выдает UNKNOWN METHOD ERROR.
Я ставлю CORS, но все еще не работает.
public function registration_post() {
// Get the post data
$first_name = $this->post('first_name');
$last_name = $this->post('last_name');
$email = $this->post('email');
$password = $this->post('password');
$phone = $this->post('phone');
$address1 = $this->post('address1');
$address2 = $this->post('address2');
$city= $this->post('city');
$zip= $this->post('zip');
$country = $this->post('country');
$state = $this->post('state');
// $creation_date= time();
// Validate the post data
if(!empty($first_name) && !empty($email) && !empty($password)){
// Check if the given email already exists
$con['returnType'] = 'count';
$con['conditions'] = array(
'email' => $email,
);
$userCount = $this->user_model->getRow($con);
// print_r($userCount);exit;
if($userCount > 0){
// Set the response and exit
$this->response("The given email already exists.", REST_Controller::HTTP_BAD_REQUEST);
}else{
// Insert user data
$userData = array(
'username' => $first_name,
'surname' => $last_name,
'email' => $email,
'password' => sha1($password),
//'creation_date' =>$creation_date
);
$insert = $this->user_model->insert($userData);
// Check if the user data is inserted
if($insert){
// Set the response and exit
$this->response([
'status' => TRUE,
'message' => 'The user has been added successfully.',
'data' => $insert
], REST_Controller::HTTP_OK);
}else{
// Set the response and exit
$this->response("Some problems occurred, please try again.", REST_Controller::HTTP_BAD_REQUEST);
}
}
}else{
// Set the response and exit
$this->response("Provide complete user info to add.", REST_Controller::HTTP_BAD_REQUEST);
}
}
Показывает ошибку. Должен показать ответ.