php - Simple cURL request ignored by the server -
for days i'm trying make connection web server remote server via curl, , far failed. try contacted hosting company , said server support curl lib. use simple way testing using codes below. print_r($array);
returning array without parameter inside array()
when should return parameters. hope can have better understanding of issue , provide answer it, many thanks.
send.php in remote server
<?php $number= '12345'; $status= 'success'; $msg = 'transaction success!'; $curlhandle = curl_init(); curl_setopt($curlhandle, curlopt_url, 'http://mywebsite.org/test.php'); curl_setopt($curlhandle, curlopt_post, 1); curl_setopt($curlhandle, curlopt_header, 0); curl_setopt($curlhandle, curlopt_postfields, 'number='.$number.'&status='.$status.'&msg ='.$msg); curl_setopt($curlhandle, curlopt_returntransfer, true); curl_setopt($curlhandle, curlopt_ssl_verifypeer, false); curl_setopt($curlhandle, curlopt_ssl_verifyhost, 2); curl_setopt($curlhandle,curlopt_followlocation,true); curl_setopt($curlhandle, curlopt_httpheader, array('content-type: application/x-www-form-urlencoded')); if (!curl_exec($curlhandle)) { echo 'an error has occurred: ' . curl_error($curlhandle); } else { echo 'everything successful'; } $array = curl_exec($curlhandle); print_r($array); curl_close($curlhandle); ?>
test.php in web server
<?php print_r($_post); ?>
less more.
may work :
<?php $number= '12345'; $status= 'success'; $msg = 'transaction success!'; $curlhandle = curl_init(); curl_setopt($curlhandle, curlopt_url, 'http://mywebsite.org/test.php'); curl_setopt($curlhandle, curlopt_post, 1); curl_setopt($curlhandle, curlopt_postfields, 'number='.$number.'&status='.$status.'&msg ='.$msg); curl_setopt($curlhandle, curlopt_returntransfer, 1); curl_setopt($curlhandle, curlopt_followlocation, 1); $html = curl_exec($curlhandle); curl_close($curlhandle); echo($html); ?>
Comments
Post a Comment