Answers for "php curl post form-urlencoded"

PHP
0

php curl post application/x-www-form-urlencoded

//this send application/x-www-form-urlencoded                                                                                                     
 function httpPostXform($url, $data) {                                                                 
    $curl = curl_init($url);                                                                            
    curl_setopt($curl, CURLOPT_POST, true);                                                             
    curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($data));                                    
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);                                                   
    curl_setopt($curl, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));   
    $response = curl_exec($curl);                                                                       
    curl_close($curl);                                                                                  
    return $response;                                                                      
}                                                                                                       
$r = httpPostXform("https://www.somesite.com",array("user_id"=>10,"sex"=>"male"));
Posted by: Guest on July-05-2021

Code answers related to "php curl post form-urlencoded"

Browse Popular Code Answers by Language