簡體   English   中英

Fedex API費率請求問題,PHP

[英]Fedex API Rate request issues, php

我不知道自己在做什么錯,我已經設置了身份驗證和版本號,但是我可以通過身份驗證。

當我嘗試示例代碼時,出現以下錯誤。

Severity: ERROR
Source: prof
Code: 1000
Message: Authentication Failed

有人可以給我建議嗎? 這是代碼的第一部分,它是該示例的幾乎未修改的副本。

$path_to_wsdl = "./RateService_v18.wsdl";

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(
    'UserCredential' =>array(
        'Key' => 'PmzmlFAKEKEYVha', 
        'Password' => 'myfedex-website-password'
    )
); 
$request['ClientDetail'] = array(
    'AccountNumber' => '123456789', 
    'MeterNumber' => '123456789'
);
$request['TransactionDetail'] = array('CustomerTransactionId' => 'testing');
$request['Version'] = array(
    'ServiceId' => 'crs', 
    'Major' => '18', 
    'Intermediate' => '0', 
    'Minor' => '0'
);


$request['ReturnTransitAndCommit'] = true;
$request['RequestedShipment']['DropoffType'] = 'REGULAR_PICKUP'; // valid values REGULAR_PICKUP, REQUEST_COURIER, ...
$request['RequestedShipment']['ShipTimestamp'] = date('c');
$request['RequestedShipment']['ServiceType'] = 'INTERNATIONAL_PRIORITY'; // valid values STANDARD_OVERNIGHT, PRIORITY_OVERNIGHT, FEDEX_GROUND, ...
$request['RequestedShipment']['PackagingType'] = 'YOUR_PACKAGING'; // valid values FEDEX_BOX, FEDEX_PAK, FEDEX_TUBE, YOUR_PACKAGING, ...
$request['RequestedShipment']['TotalInsuredValue']=array('Ammount'=>100,'Currency'=>'USD');
$request['RequestedShipment']['Shipper'] = addShipper();
$request['RequestedShipment']['Recipient'] = addRecipient();
$request['RequestedShipment']['ShippingChargesPayment'] = addShippingChargesPayment();
$request['RequestedShipment']['RateRequestTypes'] = 'ACCOUNT'; 
$request['RequestedShipment']['RateRequestTypes'] = 'LIST'; 
$request['RequestedShipment']['PackageCount'] = '1';
$request['RequestedShipment']['RequestedPackageLineItems'] = addPackageLineItem1();
try 
{
    if(setEndpoint('changeEndpoint'))
    {
        $newLocation = $client->__setLocation(setEndpoint('endpoint'));
    }

    $response = $client ->getRates($request);

    if ($response -> HighestSeverity != 'FAILURE' && $response -> HighestSeverity != 'ERROR')
    {   
        $rateReply = $response -> RateReplyDetails;
        echo '<table border="1">';
        echo '<tr><td>Service Type</td><td>Amount</td><td>Delivery Date</td></tr><tr>';
        $serviceType = '<td>'.$rateReply -> ServiceType . '</td>';
        $amount = '<td>$' . number_format($rateReply->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount,2,".",",") . '</td>';
        if(array_key_exists('DeliveryTimestamp',$rateReply)){
            $deliveryDate= '<td>' . $rateReply->DeliveryTimestamp . '</td>';
        }else if(array_key_exists('TransitTime',$rateReply)){
            $deliveryDate= '<td>' . $rateReply->TransitTime . '</td>';
        }else {
            $deliveryDate='<td>&nbsp;</td>';
        }
        echo $serviceType . $amount. $deliveryDate;
        echo '</tr>';
        echo '</table>';

        printSuccess($client, $response);
    }
    else
    {
        printError($client, $response);
    } 

    writeToLog($client);    // Write to log file   

} catch (SoapFault $exception) {
   printFault($exception, $client);        
}

function addShipper(){
    $shipper = array(
        'Contact' => array(
            'PersonName' => 'Sender Name',
            'CompanyName' => 'Sender Company Name',
            'PhoneNumber' => '9012638716'),
        'Address' => array(
            'StreetLines' => array('Address Line 1'),
            'City' => 'Collierville',
            'StateOrProvinceCode' => 'TN',
            'PostalCode' => '38017',
            'CountryCode' => 'US')
    );
    return $shipper;
}
function addRecipient(){
    $recipient = array(
        'Contact' => array(
            'PersonName' => 'Recipient Name',
            'CompanyName' => 'Company Name',
            'PhoneNumber' => '9012637906'
        ),
        'Address' => array(
            'StreetLines' => array('Address Line 1'),
            'City' => 'Richmond',
            'StateOrProvinceCode' => 'BC',
            'PostalCode' => 'V7C4V4',
            'CountryCode' => 'CA',
            'Residential' => false)
    );
    return $recipient;                                      
}
function addShippingChargesPayment(){
    $shippingChargesPayment = array(
        'PaymentType' => 'SENDER', // valid values RECIPIENT, SENDER and THIRD_PARTY
        'Payor' => array(
            'ResponsibleParty' => array(
            'AccountNumber' => getProperty('billaccount'),
            'CountryCode' => 'US')
        )
    );
    return $shippingChargesPayment;
}
function addLabelSpecification(){
    $labelSpecification = array(
        'LabelFormatType' => 'COMMON2D', // valid values COMMON2D, LABEL_DATA_ONLY
        'ImageType' => 'PDF',  // valid values DPL, EPL2, PDF, ZPLII and PNG
        'LabelStockType' => 'PAPER_7X4.75');
    return $labelSpecification;
}
function addSpecialServices(){
    $specialServices = array(
        'SpecialServiceTypes' => array('COD'),
        'CodDetail' => array(
            'CodCollectionAmount' => array('Currency' => 'USD', 'Amount' => 150),
            'CollectionType' => 'ANY')// ANY, GUARANTEED_FUNDS
    );
    return $specialServices; 
}
function addPackageLineItem1(){
    $packageLineItem = array(
        'SequenceNumber'=>1,
        'GroupPackageCount'=>1,
        'Weight' => array(
            'Value' => 50.0,
            'Units' => 'LB'
        ),
        'Dimensions' => array(
            'Length' => 108,
            'Width' => 5,
            'Height' => 5,
            'Units' => 'IN'
        )
    );
    return $packageLineItem;
}

預先感謝您的任何幫助! :)

密碼不是您已經擁有的密碼。 這是他們稍后再通過電子郵件發送給您的另一封郵件。 :/

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM