Skip to content

Instantly share code, notes, and snippets.

@c0debreaker
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save c0debreaker/0de24919db3c2e2b0b99 to your computer and use it in GitHub Desktop.
Save c0debreaker/0de24919db3c2e2b0b99 to your computer and use it in GitHub Desktop.
function requestUPSRate($origin_zipcode, $dest_zip, $country_code, $carton_length, $carton_width, $carton_height, $number_of_packages, $weight_per_carton, $units_per_carton, $qty) {
$access = "XXXXXXXXXXX"; // Access License
$userid = "someuser";
$passwd = "p@ssw0rd!";
$wsdl = "ups/RateWS.wsdl";
$operation = "ProcessRate";
$endpointurl = 'https://wwwcie.ups.com/webservices/Rate';
$mode = array
(
'soap_version' => 'SOAP_1_1', // use soap 1.1 client
'trace' => 1
);
// initialize soap client
ini_set("soap.wsdl_cache_enabled", "0");
$soapUpsClient = new SoapClient($wsdl , $mode);
//set endpoint url
$soapUpsClient->__setLocation($endpointurl);
//create soap header
$usernameToken['Username'] = $userid;
$usernameToken['Password'] = $passwd;
$serviceAccessLicense['AccessLicenseNumber'] = $access;
$upss['UsernameToken'] = $usernameToken;
$upss['ServiceAccessToken'] = $serviceAccessLicense;
$header = new SoapHeader('http://www.ups.com/XMLSchema/XOLTWS/UPSS/v1.0','UPSSecurity',$upss);
$soapUpsClient->__setSoapHeaders($header);
return $soapUpsClient->__soapCall($operation, array(processRate($origin_zipcode, $dest_zip, $country_code, $carton_length, $carton_width, $carton_height, $number_of_packages, $weight_per_carton, $units_per_carton, $qty)));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment