Silahkan Melihat Tutorial di website kami dengan nyaman ENJOY YOUR LIFE ☕

How to pass variables via PHP CURL

How to pass variables via PHP CURL

$message="Thank you";
$phone = 123456789;
$url = 'http://example.com';


$fields = array('phone'=>$phone,'source'=>'test','message'=>$message);
$fields_string='';


foreach($fields as $key=>$value) {  $fields_string .= $key.'='.$value.'&'; }
rtrim($fields_string, '&');


$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_POST, count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string);
$result = curl_exec($ch);
curl_close($ch);




0 komentar:

Post a Comment

How to pass variables via PHP CURL