Fedex API возвращает этот массив ошибок (0) {}?

Я использую библиотеку Codeigniter для получения ставок FedEx. Я создал свою собственную библиотеку для получения ставок, и я получаю данные на своем контроллере, который обрабатывает запрос, но возвращает мне ошибку массива (0) {}, я много искал, я не могу найти почему он возвращает массив 0, что это за ошибка, что я делаю неправильно. Файл моей библиотеки.

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

класс федералдекс {

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;
    }

person Ahmad Saad    schedule 20.01.2015    source источник


Ответы (1)


из последнего вы можете увидеть строку

Номер строки ошибки: $amount = $rateReply->RatedShipmentDetails[0]->ShipmentRateDetail->TotalNetCharge->Amount;

Правильно: $amount = $rateReply->RatedShipmentDetails->ShipmentRateDetail->TotalNetCharge->Amount;

person Rahul    schedule 21.05.2015