What is wrong with this cURl code
Posted: Mon May 05, 2008 8:26 am
Hi ive written a class for database which extend another class for other functionnalities.within this class there the function that does an API call
here is it
if i uncomment the echo $apirul .$param is shows how it should be.If i copy it and then paste in the address bar it works.But from the function it's not working.
the var_dump displays bool(false).I've even echo the $param and replaced it in the CURLOPT_POSTFIELDS ,same result.but the echo $apirul .$param generated y the function works in the address bar.I'm confused .....
.I'm on time limit too.Can anyone help!!
here is it
Code: Select all
function iwalletapicall($apiurl,$api_version,$i_mode, $token, $amount, $custref, $comment1, $service_type, $unit_price, $item, $qty, $merchant_email,$merchant_key)
{
$param = "api_version=$api_version&i_mode=$i_mode&token=$token&amount=$amount&cust_ref=$custref&comment1=$comment1&service_type=$service_type&unit_price=$unit_price&item=$item&quantity=$qty&merchant_email=$merchant_email&merchant_key=$merchant_key";
//echo $apiurl.$param;
$req = curl_init();
curl_setopt($req, CURLOPT_URL,$apiurl); // set url to post to
curl_setopt($req, CURLOPT_RETURNTRANSFER, 1); // return into a variable
curl_setopt($req, CURLOPT_POST, 1); // set POST method
curl_setopt($req, CURLOPT_POSTFIELDS, $param); // add POST fields
$exec = curl_exec($req); // run the whole process
curl_close($req);
//$response = explode(':',$exec);
/*if($response[0] == "Error")
{
$this->sendAlert("admin@localhost",$response);
echo "Unexpected technical problem. Please try again later";
}
else
{*/
var_dump($exec);
//}
}
the var_dump displays bool(false).I've even echo the $param and replaced it in the CURLOPT_POSTFIELDS ,same result.but the echo $apirul .$param generated y the function works in the address bar.I'm confused .....