コード例 #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 {
コード例 #2
0
	    $childRequest['TransactionDetail'] = array('CustomerTransactionId' => '*** Ground Domestic MPS Shipping Request - Child using PHP ***');
	    $childRequest['Version'] = array(
	    	'ServiceId' => 'ship', 
	    	'Major' => '17', 
	    	'Intermediate' => '0', 
	    	'Minor' => '0'
	    );
	    $childRequest['RequestedShipment'] = array(
	    	'ShipTimestamp' => date('c'),
			'DropoffType' => 'REGULAR_PICKUP', // valid values REGULAR_PICKUP, REQUEST_COURIER, DROP_BOX, BUSINESS_SERVICE_CENTER and STATION
			'ServiceType' => 'FEDEX_GROUND', // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
			'PackagingType' => 'YOUR_PACKAGING', // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
			'Shipper' => addShipper(),
			'Recipient' => addRecipient(),
			'ShippingChargesPayment' => addShippingChargesPayment(),
			'LabelSpecification' => addLabelSpecification(), 
			'MasterTrackingId' => $masterResponse->CompletedShipmentDetail->MasterTrackingId,
			'RateRequestTypes' => array('ACCOUNT', 'LIST'), // valid values ACCOUNT and LIST
			'PackageCount' => 2,
			'RequestedPackageLineItems' => array(
				'0' => addPackageLineItem2()
			)
	    );                                                                                                                                                                                                                                                                
	    $childResponse = $client->processShipment($childRequest); // FedEx web service invocation  
	    
	    writeToLog($client);    // Write to log file
	    
	    if ($childResponse->HighestSeverity != 'FAILURE' && $childResponse->HighestSeverity != 'ERROR'){
	        printSuccess($client, $childResponse);
	
	        $fp = fopen(SHIP_CODCHILDLABEL_1, 'wb');