function getUPSprice ($shipType,$sendZipcode,$recieveZipcode,$recieveCountry,$weight) {
$tmp = "AppVersion=1.2&AcceptUPSLicenseAgreement=yes&ResponseType=application/x-ups-rss&ActionCode=3".
"&RateChart=Regular+Daily+Pickup&DCISInd=0&SNDestinationInd1=0&SNDestinationInd2=0&ResidentialInd=0&PackagingType=00".
"&ServiceLevelCode=$shipType&ShipperPostalCode=".substr($sendZipcode, 0, 5)."&ConsigneePostalCode=". substr($recieveZipcode, 0, 5).
"&ConsigneeCountry=$recieveCountry&PackageActualWeight=$weight&DeclaredValueInsurance=0\n\r";
$request = "POST /using/services/rave/qcost_dss.cgi HTTP/1.0\nContent-type: application/x-www-form-urlencoded\nContent-length: " .
strlen($tmp) . "\n\n" . $tmp;
$this->socket = fsockopen("www.ups.com", 80);
fputs($this->socket, $request);
strtok(fread ($this->socket, 4096), "%");
for ($i = 0; $i < 12 ;$i++)
$price = strtok("%");
fclose($this->socket);
return($price);
}
//print("||". getUPSprice(1,57701,57703,1,13.0) ."||");
?>
|