Created
December 17, 2024 09:20
-
-
Save shohag-cse-knu/cab81e84be0474eb9104b98953f21aec to your computer and use it in GitHub Desktop.
POST API call using curl in PHP Codeigniter
This file contains hidden or 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
<?php | |
$url = base_url().'index.php/controller_name/function_name'; | |
$ch = curl_init($url); | |
$id = 1; | |
$code = 'DHA'; | |
$myvars = 'id='.$id.'&code='.$code; | |
curl_setopt( $ch, CURLOPT_POST, 1); | |
curl_setopt( $ch, CURLOPT_POSTFIELDS, $myvars); | |
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1); | |
curl_setopt( $ch, CURLOPT_HEADER, 0); | |
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1); | |
$response = curl_exec( $ch ); | |
curl_close($ch); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment