Hi all, I've got so far with debugging this but can't get any further. Appreciate that this post might not have the info you need, but it would be great for some pointers on how I could go about solving this - I've hit a wall.
I'm using cURL to make a call to a paypal server. It works fine until I start using the Auth component in the controller that makes the call. Then (even when I have $this->Auth->allow('*'); in the beforeFilter) curl_exec fails. My curl_init and curl_setopt functions are all working fine. Cheers if you can help. Michael Here is the relevant code: Anything else you would like to know? var $components = array('Email', 'Auth'); function beforeFilter() { $this->Auth->allow('*'); } function _fetchData($unique_id, $submiturl, $data) { // get data ready for API $user_agent = $_SERVER['HTTP_USER_AGENT']; // Here's your custom headers; adjust appropriately for your setup: $headers[] = "Content-Type: text/namevalue"; //or text/xml if using XMLPay. $headers[] = "Content-Length : " . strlen ($data); // Length of data to be passed // Here I set the server timeout value to 45, but notice below in the cURL section, I set the timeout // for cURL to 90 seconds. You want to make sure the server timeout is less, then the connection. $headers[] = "X-VPS-Timeout: 45"; $headers[] = "X-VPS-Request-ID:" . $unique_id; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $submiturl); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt($ch, CURLOPT_HEADER, 1); // tells curl to include headers in response curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // return into a variable curl_setopt($ch, CURLOPT_TIMEOUT, 90); // times out after 90 secs curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); // this line makes it work under https curl_setopt($ch, CURLOPT_POSTFIELDS, $data); //adding POST data curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2); //verifies ssl certificate curl_setopt($ch, CURLOPT_FORBID_REUSE, TRUE); //forces closure of connection when done curl_setopt($ch, CURLOPT_POST, 1); //data sent as POST $i=1; while ($i++ <= 1) { $result = curl_exec($ch); $headers = curl_getinfo($ch); if ($headers['http_code'] != 200) { sleep(5); // Let's wait 5 seconds to see if its a temporary network issue. } else if ($headers['http_code'] == 200) { break; } } if ($headers['http_code'] != 200) { echo '<h2>General Error!</h2>'; echo '<h3>Unable to receive response from PayPal server.</h3><p>'; echo '<h4>Verify host URL of '.$submiturl.' and check for firewall/ proxy issues.</h4>'; curl_close($ch); exit; } curl_close($ch); $result = strstr($result, "RESULT"); // echo $result; // prepare responses into array $proArray = array(); while(strlen($result)){ // name $keypos= strpos($result,'='); $keyval = substr($result,0,$keypos); // value $valuepos = strpos($result,'&') ? strpos($result,'&'): strlen($result); $valval = substr($result,$keypos+1,$valuepos-$keypos-1); // decoding the respose $proArray[$keyval] = $valval; $result = substr($result,$valuepos+1,strlen($result)); } return $proArray; } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CakePHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---