Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
联邦快递API费率请求问题,php_Php_Api_Fedex - Fatal编程技术网

联邦快递API费率请求问题,php

联邦快递API费率请求问题,php,php,api,fedex,Php,Api,Fedex,我不知道我做错了什么我已经设置了身份验证和版本号,但是我可以得到身份验证 我在尝试示例代码时遇到以下错误 Severity: ERROR Source: prof Code: 1000 Message: Authentication Failed 有谁能在这方面给我建议吗?!这是代码的第一部分,它是示例的一个勉强修改过的副本 $path_to_wsdl = "./RateService_v18.wsdl"; ini_set("soap.wsdl_cache_enabled", "0");

我不知道我做错了什么我已经设置了身份验证和版本号,但是我可以得到身份验证

我在尝试示例代码时遇到以下错误

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;
}
$path_to_wsdl=“./RateService_v18.wsdl”;
ini_集(“soap.wsdl_缓存已启用”,“0”);
$client=newsoapclient($path_to_wsdl,array('trace'=>1));//提到http://us3.php.net/manual/en/ref.soap.php 更多信息
$request['WebAuthenticationDetail']=数组(
“UserCredential”=>数组(
“密钥”=>“pmzmlMakeKeyvha”,
“密码”=>“我的联邦快递网站密码”
)
); 
$request['ClientDetail']=数组(
“AccountNumber”=>“123456789”,
“MeterNumber”=>“123456789”
);
$request['TransactionDetail']=array('CustomerTransactionId'=>'testing');
$request['Version']=数组(
'ServiceId'=>'crs',
“少校”=>“18”,
“中间”=>“0”,
“次要”=>“0”
);
$request['ReturnTransitAndCommit']=true;
$request['requestedshipping']['DropoffType']='REGULAR_PICKUP';//有效值定期取货,请求快递。。。
$request['requestedshipping']['shipptimestamp']=日期('c');
$request['requestedshipping']['ServiceType']='INTERNATIONAL_PRIORITY';//有效值标准夜、优先级夜、联邦快递地面。。。
$request['requestedshipping']['PackagingType']='YOUR_PACKAGING';//有效值联邦快递箱、联邦快递包装、联邦快递管、您的包装。。。
$request['requestedshipping']['totalinsuraredvalue']=array('amount'=>100,'Currency'=>'USD');
$request['requestedshipping']['Shipper']=addShipper();
$request['requestedshipping']['Recipient']=addRecipient();
$request['requestedshipping']['ShippingChargesPayment']=addShippingChargesPayment();
$request['requestedshipping']['RateRequestTypes']='ACCOUNT';
$request['requestedshipping']['RateRequestTypes']='LIST';
$request['requestedshipping']['PackageCount']='1';
$request['requestedShipping']['RequestedPackageLineItems']=addPackageLineItem1();
尝试
{
if(setEndpoint('changeEndpoint'))
{
$newLocation=$client->_setLocation(setEndpoint('endpoint'));
}
$response=$client->getRates($request);
如果($response->HighestSeverity!=“FAILURE”&&$response->HighestSeverity!=“ERROR”)
{   
$rateReply=$response->RateReplyDetails;
回声';
echo“服务类型数量交付日期”;
$serviceType='.$rateReply->serviceType';
$amount='$'.数字\格式($rateReply->RatedShipmentDetails[0]->ShipmentRateDetails->TotalNetCharge->金额,2,“,”,”);
如果(数组\键\存在('DeliveryTimestamp',$rateReply)){
$deliveryDate='.$rateReply->DeliveryTimestamp';
}else if(数组\键\存在('TransitTime',$rateReply)){
$deliveryDate='.$rateReply->TransitTime';
}否则{
$deliveryDate='';
}
echo$serviceType.$amount.$deliveryDate;
回声';
回声';
printSuccess($client$response);
}
其他的
{
打印错误($client$response);
} 
writeToLog($client);//写入日志文件
}catch(SoapFault$异常){
printFault($exception,$client);
}
函数addShipper(){
$shipper=数组(
“联系人”=>数组(
'PersonName'=>'Sender Name',
'CompanyName'=>'Sender CompanyName',
“电话号码”=>“9012638716”),
'地址'=>数组(
“StreetLines”=>数组(“地址行1”),
“城市”=>“科利尔维尔”,
'StateOrProvinceCode'=>'TN',
“PostalCode”=>“38017”,
'CountryCode'=>'US')
);
返回$shipper;
}
函数addRecipient(){
$recipient=数组(
“联系人”=>数组(
'PersonName'=>'Recipient Name',
'公司名称'=>'公司名称',
“电话号码”=>“9012637906”
),
'地址'=>数组(
“StreetLines”=>数组(“地址行1”),
“城市”=>“里士满”,
'StateOrProvinceCode'=>'BC',
“PostalCode”=>“V7C4V4”,
“CountryCode”=>“CA”,
“住宅”=>假)
);
返回$recipient;
}
函数addShippingChargesPayment(){
$shippingChargesPayment=阵列(
'PaymentType'=>'SENDER',//收件人、发件人和第三方的有效值
“付款人”=>数组(
“ResponsibleParty”=>数组(
'AccountNumber'=>getProperty('billaccount'),
'CountryCode'=>'US')
)
);
返回$shippingChargesPayment;
}
函数addLabelSpecification(){
$labelSpecification=数组(
'LabelFormatType'=>'COMMON2D',//有效值COMMON2D,仅标签数据
'ImageType'=>'PDF',//有效值DPL、EPL2、PDF、ZPLII和PNG
“LabelStockType”=>“PAPER_7X4.75”);
返回$labelSpecification;
}
函数addSpecialServices(){
$specialServices=阵列(
'SpecialServiceTypes'=>数组('COD'),
“CodDetail”=>数组(
“CodCollectionAmount”=>array('Currency'=>'USD','Amount'=>150),
'CollectionType'=>'ANY')//任何担保资金
);
返回$specialServices;
}
函数addPackageLineItem1(){
$packageLineItem=数组(
“SequenceNumber”=>1,
“GroupPackageCount”=>1,
“权重”=>数组(
“值”=>50.0,
“单位”=>“磅”
),
“维度”=>数组(
“长度”=>108,
“宽度”=>5,
“高度”=>5,
'单位'=>'英寸'
)
);
返回$packageLineItem;
}

提前感谢您的帮助!:)

密码不是您已有的密码。这是他们稍后给你发电子邮件的另一封信/

该密码不是您的密码,您已经