php - If that possible to pass parameter to curl in codeigniter? -




i have curl controller named curl_run_experiment, contained post_test function deal update user data. function like:

function post_test(){     $url = "http://{$_server['http_host']}/{$pathname}/update";      $data = array(         'user_id'=>'',         'fullname'=>'testing',         'phone'=>'+6270707070707'     );      //init     $ch = curl_init();      //set opt     curl_setopt($ch, curlopt_url, $url);     curl_setopt($ch, curlopt_header, 0);     curl_setopt($ch, curlopt_returntransfer,1);     curl_setopt($ch, curlopt_post, 1);     curl_setopt($ch, curlopt_postfields, $data);      //exec     $output = curl_exec($ch);      //close     curl_close($ch);      echo $output; } 

my question can put parameter post_test function like:

function post_test($user_id){     //something } 

so when access link example (http://localhost/{$pathname}/curl_run_experiment/post_test/123), curl function recognize '123' value of $user_id.

first , foremost curl in php , why used?

php supports libcurl, library created daniel stenberg, allows connect , communicate many different types of servers many different types of protocols. libcurl supports http, https, ftp, gopher, telnet, dict, file, , ldap protocols. libcurl supports https certificates, http post, http put, ftp uploading (this can done php's ftp extension), http form based upload, proxies, cookies, , user+password authentication.

now if want hit curl request url accepts post parameter can use curl_post. , if want hit curl request url in response gives response can use curlget

e.g curl get:

$employee_data_url = "https://urltoanyapi"; $employee_data = curlget($employee_data_url); 

e.g curl post:

$params['emailid'] = $email; $params['password'] = $password; $login_url ="http://url_any.com";  $response = curlpost($login_url, $params); 




wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -

python - Read npy file directly from S3 StreamingBody -