Fedex api returns 这个错误数组(0){ }?

Fedex api returns this error array(0) { }?

我正在使用 Codeigniter 库来获取联邦快递费率我已经创建了自己的库来获取费率并且我在我的控制器上抓取了请求处理的数据但是它的 returns 我的数组(0){}错误,我已经搜索了很多我找不到为什么 returns array 0 这个错误是什么我做错了什么。 我的库文件。

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class联邦快递{

function rates(){

    $weight = '46';
    $this->path_to_wsdl = base_url()."assets/wsdl/RateService_v14.wsdl";

    $key                = 'acess_key';
    $password           = 'password';
    $shipAccount        = 'accound_no';
    $meter              = 'meter_no';
    $dropofftype        = 'dropofftype';
    $service            = 'FEDEX_1_DAY_FREIGHT';
    $package            = 'package';
    $handling_method    = 'price';
    $handling_amount    = '5';
    $pkg_width          = '6';
    $pkg_height         = '6';
    $pkg_length         = '5';
    $insurance          = true;
    $billAccount        = $shipAccount;

    // Build Request

    $package = $this->package_types['FEDEX_10KG_BOX'] = 'FEDEX_10KG_BOX';
    $dropofftype = $this->dropoff_types['REGULAR_PICKUP'] = 'REGULAR_PICKUP';


    ini_set("soap.wsdl_cache_enabled", 0);
    ini_set('soap.wsdl_cache_ttl',0);

    $client = new SoapClient($this->path_to_wsdl, array('trace' => 1, "exception" => 0));
     // Refer to http://us3.php.net/manual/en/ref.soap.php for more information

    $request['WebAuthenticationDetail'] = array(
        'UserCredential' =>array(
            'Key' => $key,
            'Password' => $password
        )
    ); 
    $request['ClientDetail'] = array(
        'AccountNumber' => $shipAccount,
        'MeterNumber' => $meter
    );
    $request['TransactionDetail'] = array('CustomerTransactionId' => '*** Rate Request v14 using PHP ***');

    $request['Version'] = array(
        'ServiceId' => 'crs', 
        'Major' => '14', 
        'Intermediate' => '0', 
        'Minor' => '0'
    );

    $request['ReturnTransitAndCommit'] = false;
    $request['RequestedShipment']['RequestedCurrency'] ='$';
    $request['RequestedShipment']['DropoffType'] = $dropofftype;
    $request['RequestedShipment']['ShipTimestamp'] = date('c');
    $request['RequestedShipment']['PackagingType'] = $package; 

    if($insurance=='yes')
    {
        $request['RequestedShipment']['TotalInsuredValue']=array(
            'Ammount'=> '5',
            'Currency'=> '$',
        );
    }

    $request['RequestedShipment']['Shipper'] = array(
            'Contact' => array(
                'CompanyName' => 'companyname',
                'EMailAddress' => 'EMailAddress'
            ),
            'Address' => array(
                'StreetLines' => 'StreetLines',
                'City' => 'City',
                'StateOrProvinceCode' => 'StateOrProvinceCode',
                'PostalCode' => 'PostalCode',
                'CountryCode' => 'CountryCode'
            )
        );


    $request['RequestedShipment']['Recipient'] =  array(
            'Contact' => array(
                'PersonName' => " ",
                'CompanyName' => '',
                'PhoneNumber' => '',
            ),
            'Address' => array(
                'StreetLines' => '',
                'City' => '',
                'StateOrProvinceCode' => '',
                'PostalCode' => 'postalcode',
                'CountryCode' => '',
                //'Residential' => false   // no way to determine this
            )
        );

    $request['RequestedShipment']['RateRequestTypes'] = 'LIST'; 
    $request['RequestedShipment']['PackageCount'] = '1';
    $request['RequestedShipment']['RequestedPackageLineItems'] =  array(
            'SequenceNumber'=>1,
            'GroupPackageCount'=>1,
            'Weight' => array(
                'Value' => $weight,
                'Units' => 'lbs'
            ),
            'Dimensions' => array(
                'Length' => $pkg_length,
                'Width' => $pkg_width,
                'Height' => $pkg_height,
                'Units' => 'feet'
            )
        );

    // Send the request to FedEx
    $response = $client->getRates($request);

    // Handle response
    if ($response->HighestSeverity != 'FAILURE' && $response->HighestSeverity != 'ERROR' )
    {

        if(!is_array(@$response->RateReplyDetails))
        {
            return array(); // No Results
        }

        foreach ($response->RateReplyDetails as $rateReply)
        {         
            if(in_array($rateReply->ServiceType, $service))
            {

                $amount = $rateReply->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount;

                if(is_numeric($handling_amount)) // valid entry?
                {
                    if($handling_method=='price')
                    {
                        $amount += $handling_amount;
                    }
                    elseif($handling_method=='percent')
                    {
                        $amount += $amount * ($handling_amount/100);
                    }
                }

                $rates[$this->service_list[$rateReply->ServiceType]] = number_format($amount,2,".",",");
            }
        }

        return $rates;
    }
    else
    {
        return array(); // fail
    }

}

}

我的控制器。

public function fedex(){
    $this->load->library('fedex/fedex');
    $fedex = new Fedex; 
    $weight = 46;
    $dest_zip = '10001';
    $fexed_rates = $fedex->rates();
    var_dump($fexed_rates); die;
    }

从最后一行你可以看到

错误行号:$amount = $rateReply->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount;

正确: $amount = $rateReply->RatedShipmentDetails->ShipmentRateDetail->TotalNetCharge->Amount;