“状态”:false,“错误”:“未知方法”在CODEIGNITER REST API中的邮递员的http调用中

时间:2019-11-03 05:46:00

标签: api codeigniter-3

我的域指向cloudflare,当我检查其余API时,使用https的域给出了正确的响应,但是使用http给出了未知的方法错误。

我放了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);
        }
    }

显示错误。 它应该显示响应。

0 个答案:

没有答案