PHP InterShipper class

Version 1.5

Description

This tag will return a multi-dimensional array containing shipping methods and rates for shipping a package using your choice of several shipping carriers. All necessary information for getting accurate rate quotes can be specified in request. You must have an account with InterShipper, and agree to their terms of service to use this class. Accounts are available at no cost, and no charge is made for the service. Please see InterShipper's site for further information. Use of this tag implies agreement with InterShipper's licensing requirements.

Release Notes:

5 APR 2000: Version 1.5 InterShipper now supports the Track() method for retrieving tracking information on shipments. The version number was brought into line with the ColdFusion version. Changed separator for carriers to comma for safety and consistency. Pipe symbol will continue to work, but is deprecated.
29 FEB 2000: Version 0.9 Initial development and testing. All parameters are active, and the class is fully functional. It just requires better data-validation and error-control.

Usage

<?
	include('intershipper.php');
	
	// Create a class instance
	$IShip = new InterShipper();
	
	// Set parameters
	$IShip->setVar("email", "youraccountemail");
	$IShip->setVar("password", "yourpassword");
	$IShip->setVar("Opostalcode", "85224");
	$IShip->setVar("Dpostalcode", "19605");
	$IShip->setVar("carriers", "ANX|FDX|UPS|USPS");
	$IShip->setVar("weight", 1.1);
	
	// Send the request
	if($IShip->Quote(30))
	{
		// If it succeeds...
		// $quote will hold the array
		$quote = $IShip->getQuote();
	}
	else
	{
		// Print the error message
		echo $IShip->getError();
	}
?>

Security:

Please note that these requests are made in clear text. Technically, the only sensitive information is the email and password fields, and quite frankly, the risk is very low since there's not much that can be done with them other than request shipping info. However, if this is a consideration, InterShipper supports having these two fields encrypted using DES56, and Base64 encoded. Just encrypt the field using your IP address as the key, Base64 encode the result, and use that for the parameter. InterShipper also supports the use of arbitrary keys by setting the key on their website. For more information, please see the API documentation at InterShipper's website.

Functions:

boolean setVar($variable, $value)Used to set a parameter's value. Returns false if the parameter is invalid or if the data is not appropriate for the parameter. Returns true otherwise.
boolean getData($timeout, $request_type)Used to perform a request. The timeout value is the number of seconds to wait for the answer. The request_type is either "QUOTE" or "TRACK". Returns true if the request succeeds. Returns false if any error occured.
boolean Quote($timeout)Alias for getData($timeout, "QUOTE"). Deprecated.
boolean Track($timeout)Alias for getData($timeout, "TRACK"). Deprecated.
array getQuote()Returns an array of shipping methods. Note that this array may be empty even on a successful request if there were no methods that fit the request.
array getTrack()Returns an array of tracking information.
string getError()Returns the text description of the last error that occurred.

Parameters:

ALL Requests
emailRequiredSpecifies the email address provided to InterShipper when the InterShipper account was created.
passwordRequiredThe password for the InterShipper account.
carriersOptionalSpecifies the carriers to be queried for rates. Multiple carriers should be comma-separated, ie: FDX,UPS,USPS.
    Acceptable Values:
  • ABX - Airborne Express
  • ANX - Airnet Express
  • BAX - BAX Global
  • DHL - DHL Airways
  • EWW - Emery WorldWide
  • FDX - FedEx Express
  • RPS - FedEx Ground - formerly RPS
  • UPS - United Parcel Service
  • USPS - US Postal Service
  • ALL - All available carriers.
Defaults to ALL
Quote() Requests
OaddressOptionalSpecifies the origin address.
OcityVariesSpecifies the origin city. (Mandatory for countries that do not use postal codes.)
OstateOptionalSpecifies the origin state or province.
OcountryOptionalSpecifies the origin country. Defaults to US. This attribute can take most any recognizable country designator.
OpostalcodeVariesSpecifies the origin postal code (Zip code.) This is mandatory for countries that use postal codes.
OresidentialOptionalSpecifies that the pickup location is residential. Acceptable values are YES or NO. Defaults to NO.
DaddressOptionalSpecifies the destination address.
DcityVariesSpecifies the destination city. (Mandatory for countries that do not use postal codes.)
DstateOptionalSpecifies the destination state or province.
DcountryOptionalSpecifies the destination country. Defaults to US. This attribute can take most any recognizable country designator.
DpostalcodeVariesSpecifies the destination postal code (Zip code.) This is mandatory for countries that use postal codes.
DresidentialOptionalSpecifies that the delivery location is residential. Acceptable values are YES or NO. Defaults to YES.
weightRequiredSpecifies the weight of the package.
weightunitsOptionalSpecifies the units the weight is specified in.
    Acceptable Values:
  • LB - Pounds (default)
  • OZ - Ounces
  • KG - Kilograms
  • G - Grams
dimensionunitsOptionalSpecifies the units used for measuring the dimensions of the package. Required when LENGTH, WIDTH and HEIGHT are provided.
    Acceptable Values:
  • IN - Inches (default)
  • FT - Feet
  • CM - Centimeters
  • M - Meters
lengthOptionalSpecifies the length of the package.
widthOptionalSpecifies the width of the package.
heightOptionalSpecifies the height of the package.
shipdateOptionalSpecifies the date the package will be sent. Defaults to the current date.
shipmethodOptionalSpecifies the pickup method.
    Acceptable Values:
  • SCD - Regularly Scheduled Pickup (default)
  • DRP - Will be dropped off at the carrier's location
  • PCK - Special (On-Call) Pickup
packagingOptionalSpecifies the type of packaging.
    Acceptable Values:
  • BOX - Any standard or specialized, square or rectangular, box. (Default)
  • LTR - Any flat item resembling a letter that is longer than 11.5 inches or taller than 6.125 inches or thicker than 0.25 inches. In most cases, you will also want to set STYLE to CAR to use the carrier's letter packaging. You will also want to make sure you enter the exact weight of the letter, because most carriers charge more for letters that weigh over 8 ounces.
  • ENV - Any flat item in an envelope that is too small to be classified as a letter under the terms above.
  • PAK - Indicates that you will be using a 'pak', which is an envelope for shipping items larger than a regular 'letter' can hold. It is usually made of Mylar, Tyvek, or another waterproof material. In most cases, you will also want to set STYLE to CAR to use the carrier's packaging.
  • TUB - Any item that is shipped in a tube.
  • ROL - Any item that is shipped on a roll or spool.
  • TIR - Used when shipping tires
  • FLM - Indicates that the item you're shipping is a film case.
  • CAN - Used when you are shipping a can or pail that is not completely enclosed in a box.
  • TRE - Used when shipping a shrub or a tree that isn't completely enclosed in a box.
  • ENC - Indicates that the item you are shipping is not completely enclosed in any shipping container defined in this list.
packagematerialOptionalSpecifies the type of packaging material.
    Acceptable Values:
  • CBP - Cardboard or Paper (Default)
  • GLS - Glass
  • MTL - Metal
  • PLA - Plastic
  • WOD - Wood
packagestyleOptionalSpecifies the style of packaging.
    Acceptable Values:
  • NON - None of the below options. (Default)
  • CAR - Indicates that the packaging material you will be using is provided by the carrier, and has the carrier's name and logo imprinted on it. This is usually used for letters, paks, tubes, and specialty boxes.
  • BND - Indicates that the package is bound with metal straps. Straps made of other material do not require this attribute.
  • STR - Indicates that the package has strap-type closures. This is typically used in conjunction with a film case.
contentOptionalDescribes the contents of the shipment.
    Acceptable Values:
  • NON - None of the below options. (Default)
  • JWL - Jewelry. (Do not select this for costume jewelry.)
  • ADV - Advertising, or other bound printed material.
  • BOK - Books, or other unbound printed material.
  • BLD - Matter for the blind.
  • ELC - Electronic media such as tapes, CD's, videos or computer software.
  • PER - Perishables or live animals.
  • MED - Medical materials.
contentdangerOptionalUsed when shipping dangerous materials.
    Acceptable Values:
  • NON - None (Default)
  • IDG - Inaccessible dangerous goods. This includes toxic, infectious substances, radioactive material, dry ice, ORM-D and non-flammable gas without a "Cargo Aircraft Only" label.
  • ADG - Accessible dangerous goods. This includes explosives, flammable gas, liquid and solid (spontaneously combustible, dangerous when wet), corrosive material, and oxidizer, organic peroxide and non-flammable gas with a "Cargo Aircraft Only" label.
liquidvolumeOptionalIf the shipment contains liquid, this tag is required and should contain the volume of liquid. Can be any numeric value, including decimals.
liquidunitsVariesRequired when LIQUIDVOLUME is used.
    Acceptable Values:
  • OZ - Ounces
  • G - Gallons
  • QT - Quarts
  • L - Liters
CODvalueOptionalAmount in US Dollars to collect at time of delivery.
declaredvalueOptionalAmount in US Dollars to insure your shipment for.
dutiableOptionalSpecifies whether your shipment is dutiable when shipped internationally. Should be YES or NO. Defaults to NO.
Track() Requests
trackingnumRequiredSpecifies the tracking numbers to be queried. Multiple tracking numbers should be comma-separated. If more than one is being requested, be sure that the tracking numbers are in the same order as the carriers parameter.

Return Values:

QUOTE

The getQuote() method will return a multi-dimensional array. The first dimension represents each shipping method, and the second dimension contains the details of that method.

Second Dimension Members:
quoteid The quoteID attribute gives you a reference to retrieve this quote at a later time. (From InterShipper)
carrierid The carrierid attribute is always the same for each carrier. A numeric identifier for a specific carrier.
carriername The carriername attribute is the text that you can use to describe the carrier to your end user.
methodid The methodid attribute is always the same for each method. A numeric identifier for a specific method.
methodcode The methodcode attribute is a string identifier for the method and is similar to the methodid.
methodname The methodname attribute is the text that you can use to describe the shipping method to your end user.
itemid This tag is a unique identifier for each of this particular quote's methods.
rate The rate for this shipping method.
transitdays The number of business days that the shipment will be in transit. This does not include weekends or holidays.
date The expected date of delivery. Weekends and holidays are taken into account.
time The expected time of delivery. If the shipping method has no time commitment, this value will be 23:59 (end of day).
guaranteed If this value is YES, then the date and time reported are guaranteed by the carrier. If NO, then they are estimates.
latestpickup This is the latest time that a pickup will be made by the courier. The value returned will either be a time in hh:mm 24 hour format (e.g. '18:09' which is 6:09pm) or blank. If nothing is returned, data is not available for this courier.

TRACK

The getTrack() method will return a multi-dimensional array. The first dimension represents each tracking request, and the second dimension contains the details of that method.

Second Dimension Members:
carriercode The Carrier code that was used to make the request.
trackingnumber The Tracking Number code that was used to make the request.
servicetype The Service Type name returned from the carrier. If the connection to the carrier failed, this field will contain "NO DATA RETURNED FROM CARRIER". If the tracking number is invalid or no data is available, this field will contain "INVALID OR NOT FOUND".
statuscode A numeric code representing the status of the request.
  • 1 - Successful
  • 0 - Tracking Number not found
  • -1 - Failed to connect to Carrier
statuslevel A numeric code representing the status of the shipment.
  • 1 - Delivered
  • 2 - In Transit
  • 3 - Delayed
  • 4 - Delivery was attempted
  • 5 - Unknown
statustext The text description of the status code.
scandate The date and time the last tracking entry was made for this shipment.
deliverydate The date of (anticipated) delivery for this shipment.
deliveredto The place the package was delivered to.
signatory The person who received the shipment.
location The address or company where the shipment was made.
city The city where the shipment was made.
state The state where the shipment was made.
country The country where the shipment was made.

This document and the InterShipper class code are © 1999, 2000, Desert Raven, and are released under the conditions of the GNU LGPL. InterShipper is a registered trademark of BITS, Inc. Desert Raven is not affiliated with InterShipper or BITS Inc in any way, and neither InterShipper nor BITS Inc. are responsible for the operation of this class. Questions regarding this class should be addressed to Michael Sheldon at info@desertraven.com. Questions regarding the InterShipper service should be addressed to InterShipper.

Desert Raven
P.O. Box 279
Tempe, AZ 85280-0279
480-699-1084
info@desertraven.com
http://www.desertraven.com