Hi All,
I'm using UPS as my shipping module,
and I find that vitruemart could not get shipping quotes from UPS in some cases.
after some investigation, I found that the xml result from UPS contains http headers.so the xml parser consider the xml doc as an invalid xml doc.
and my solutions as following, I hope it may help some guys. ;D
administrator/components/com_virtuemart/classes/connectionTools.class.php
Line 130:
if( $urlParts['scheme'] == 'https') {
// No PEER certificate validation...as we don't have
// a certificate file for it to authenticate the host www.ups.com against!
curl_setopt($CR, CURLOPT_SSL_VERIFYPEER, 0);
//curl_setopt($CR, CURLOPT_SSLCERT , "/usr/locale/xxxx/clientcertificate.pem");
}
/*---------------- HACK START --------------------- */
/*Don't return the headers*/
curl_setopt($CR, CURLOPT_HEADER, false);
/*---------------- HACK END --------------------- */
$result = curl_exec( $CR );
$error = curl_error( $CR );
line 252:
// $result = trim( $data ); // original
// Remove Http header xml stream
$result = preg_replace('/.*?\r\n\r\n(.*)/s', '$1', trim( $data ));
路过~~
Can you give me a better idea of where to place the second snippet of code? My line 252 is commented out as some author comments
// If didnt get content-length, something is wrong, return false.
if ( trim($data) == '' ) {
$vmLogger->err('An error occured while communicating with the server '.$urlParts['host'].'. It didn\'t reply (correctly). Please try again later, thank you.' );
return false;
}
if(strpos($url, 'zip')) {
$result = $data;
}
else {
// $result = trim( $data ); // original
// Remove Http header xml stream
$result = preg_replace('/.*?\r\n\r\n(.*)/s', '$1', trim( $data ));
}
if( is_resource($fileToSaveData )) {
fwrite($fileToSaveData, $result );
return true;
} else {
return $result;
}
Nice
Just used the second hack, works great.