Page 1 of 1

What is wrong with this cURl code

Posted: Mon May 05, 2008 8:26 am
by highjo
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

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);
                
            //}
                        
        }
 
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 ..... :crazy: .I'm on time limit too.Can anyone help!!

Re: What is wrong with this cURl code

Posted: Mon May 05, 2008 10:37 am
by highjo
So! either m posts are not interesting enough or too stupid for getting answers.What is wrong but i've noticed that for few days now i'm not getting any replies.I'm just wondering what is happening to this forum.And quick replies are one of the aspects i appreciate in this forum.If someone still have time to see my code and give some clues i'll be more than glad.Thanks