Skip to content

Instantly share code, notes, and snippets.

@bamsarts
Last active March 9, 2020 06:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bamsarts/4279a2961170d8b711606f9be0d02f56 to your computer and use it in GitHub Desktop.
Save bamsarts/4279a2961170d8b711606f9be0d02f56 to your computer and use it in GitHub Desktop.
curl post
$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