-
-
Save bamsarts/4279a2961170d8b711606f9be0d02f56 to your computer and use it in GitHub Desktop.
curl post
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$username = $this->input->post('username',TRUE); | |
$password = $this->input->post('password',TRUE); | |
$postData = "contact=" . $username . "&password=" . $password; | |
$ch = curl_init(); | |
curl_setopt($ch, CURLOPT_URL, $this->base_url."/auth/signinForsa"); | |
curl_setopt($ch, CURLOPT_HEADER, 0); | |
curl_setopt($ch, CURLOPT_POST, 1); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); | |
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); | |
$output = curl_exec($ch); | |
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE); | |
if($httpcode >= 200 && $httpcode < 300){ | |
$data = json_decode($output); | |
$this->session->set_userdata('token', $data->token); | |
echo $output; | |
}else{ | |
http_response_code(404); | |
echo $output; | |
} | |
curl_close($ch); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment