Example #1
0
// Copyright 2009, FedEx Corporation. All rights reserved.
// Version 12.0.0
require_once '../../../library/fedex-common.php';
//The WSDL is not included with the sample code.
//Please include and reference in $path_to_wsdl variable.
$path_to_wsdl = "../../../wsdl/beta/ShipService_v17.wsdl";
define('SHIP_LABEL', 'shipexpresslabel.pdf');
// PDF label file. Change to file-extension .pdf for creating a PDF label (e.g. shiplabel.pdf)
ini_set("soap.wsdl_cache_enabled", "0");
$client = new SoapClient($path_to_wsdl, array('trace' => 1));
// Refer to http://us3.php.net/manual/en/ref.soap.php for more information
$request['WebAuthenticationDetail'] = array('ParentCredential' => array('Key' => getProperty('parentkey'), 'Password' => getProperty('parentpassword')), 'UserCredential' => array('Key' => getProperty('key'), 'Password' => getProperty('password')));
$request['ClientDetail'] = array('AccountNumber' => getProperty('shipaccount'), 'MeterNumber' => getProperty('meter'));
$request['TransactionDetail'] = array('CustomerTransactionId' => '*** Express International Shipping Request using PHP ***');
$request['Version'] = array('ServiceId' => 'ship', 'Major' => '17', 'Intermediate' => '0', 'Minor' => '0');
$request['RequestedShipment'] = array('ShipTimestamp' => date('c'), 'DropoffType' => 'REGULAR_PICKUP', 'ServiceType' => 'INTERNATIONAL_PRIORITY', 'PackagingType' => 'YOUR_PACKAGING', 'Shipper' => addShipper(), 'Recipient' => addRecipient(), 'ShippingChargesPayment' => addShippingChargesPayment(), 'CustomsClearanceDetail' => addCustomClearanceDetail(), 'LabelSpecification' => addLabelSpecification(), 'CustomerSpecifiedDetail' => array('MaskedData' => 'SHIPPER_ACCOUNT_NUMBER'), 'PackageCount' => 1, 'RequestedPackageLineItems' => array('0' => addPackageLineItem1()), 'CustomerReferences' => array('0' => array('CustomerReferenceType' => 'CUSTOMER_REFERENCE', 'Value' => 'TC007_07_PT1_ST01_PK01_SNDUS_RCPCA_POS')));
try {
    if (setEndpoint('changeEndpoint')) {
        $newLocation = $client->__setLocation(setEndpoint('endpoint'));
    }
    $response = $client->processShipment($request);
    // FedEx web service invocation
    if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR') {
        printSuccess($client, $response);
        // Create PNG or PDF label
        // Set LabelSpecification.ImageType to 'PDF' for generating a PDF label
        $fp = fopen(SHIP_LABEL, 'wb');
        fwrite($fp, $response->CompletedShipmentDetail->CompletedPackageDetails->Label->Parts->Image);
        fclose($fp);
        echo 'Label <a href="./' . SHIP_LABEL . '">' . SHIP_LABEL . '</a> was generated.';
    } else {
Example #2
0
$request['Version'] = array(
	'ServiceId' => 'ship', 
	'Major' => '17', 
	'Intermediate' => '0', 
	'Minor' => '0'
);
$request['RequestedShipment'] = array(
	'ShipTimestamp' => date('c'),
	'DropoffType' => 'REGULAR_PICKUP', // valid values REGULAR_PICKUP, REQUEST_COURIER, DROP_BOX, BUSINESS_SERVICE_CENTER and STATION
	'ServiceType' => 'STANDARD_OVERNIGHT', // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_EXPRESS_SAVER
	'PackagingType' => 'YOUR_PACKAGING', // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
	'Shipper' => addShipper(),
	'Recipient' => addRecipient(),
	'ShippingChargesPayment' => addShippingChargesPayment(),
	'SpecialServicesRequested' => addSpecialServices1(), //Used for Intra-India shipping - cannot use with PRIORITY_OVERNIGHT
	'CustomsClearanceDetail' => addCustomClearanceDetail(),                                                                                                      
	'LabelSpecification' => addLabelSpecification(),
	'CustomerSpecifiedDetail' => array('MaskedData'=> 'SHIPPER_ACCOUNT_NUMBER'), 
	'PackageCount' => 1,                                       
	'RequestedPackageLineItems' => array(
		'0' => addPackageLineItem1()
	)
);



try{
	if(setEndpoint('changeEndpoint')){
		$newLocation = $client->__setLocation(setEndpoint('endpoint'));
	}