【问题标题】:Fedex PHP API Integration for indian address印度地址的 Fedex PHP API 集成
【发布时间】:2017-07-29 03:47:28
【问题描述】:

有没有人在 PHP 中集成 fedex API 来生成跟踪号和运输标签?我将以下 XML 提交给联邦快递 -

<?xml version="1.0" encoding="UTF-8"?>

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:m0="http://fedex.com/ws/ship/v19">

<SOAP-ENV:Body>

<ProcessShipmentRequest xmlns="http://fedex.com/ws/ship/v19">

<WebAuthenticationDetail>

<UserCredential>

<Key>avpSZAQRg9gu3zfm</Key>

<Password>gSmYLbjJwCYYVsoIwfp2ux2FY</Password>

</UserCredential>

</WebAuthenticationDetail>

<ClientDetail>

<AccountNumber>604794161</AccountNumber>

<MeterNumber>100339204</MeterNumber>

</ClientDetail>

<TransactionDetail>

<CustomerTransactionId>8787</CustomerTransactionId>

</TransactionDetail>

<Version>

<ServiceId>ship</ServiceId>

<Major>19</Major>

<Intermediate>0</Intermediate>

<Minor>0</Minor>

</Version>

<RequestedShipment>

<ShipTimestamp>2017-07-29T12:34:56-06:00</ShipTimestamp>

<DropoffType>REGULAR_PICKUP</DropoffType>

<ServiceType>STANDARD_OVERNIGHT</ServiceType>

<PackagingType>YOUR_PACKAGING</PackagingType>

<Shipper>

<Contact>

<PersonName>Piyush Rana</PersonName>

<CompanyName>Eclators</CompanyName>

<PhoneNumber>9925383633</PhoneNumber>

<EMailAddress>rana@gmail.com</EMailAddress>

</Contact>

<Address>

<StreetLines>14-B-5</StreetLines>

<StreetLines>DkPark</StreetLines>

<City>Surat</City>

<StateOrProvinceCode>Gujarat</StateOrProvinceCode>

<PostalCode>395007</PostalCode>

<CountryCode>IN</CountryCode>

</Address>

</Shipper>

<Recipient>

<Contact>

<PersonName>Panakj Rana</PersonName>

<CompanyName>pp</CompanyName>

<PhoneNumber>9252905058</PhoneNumber>

<EMailAddress>php.pankaj@gmail.com</EMailAddress>

</Contact>

<Address>

<StreetLines>Near yadav floor mill</StreetLines>

<StreetLines>sarvodaya basti</StreetLines>

<City>Bikaner</City>

<StateOrProvinceCode>rajasthan</StateOrProvinceCode>

<PostalCode>334004</PostalCode>

<CountryCode>IN</CountryCode>

</Address>

</Recipient>

<ShippingChargesPayment>

<PaymentType>SENDER</PaymentType>

<Payor>

<ResponsibleParty>

<AccountNumber>604794161</AccountNumber>

<Contact>

<ContactId>12345</ContactId>

<PersonName>shanu rana</PersonName>

</Contact>

</ResponsibleParty>

</Payor>

</ShippingChargesPayment>

<SpecialServicesRequested>

<SpecialServiceTypes>ELECTRONIC_TRADE_DOCUMENTS</SpecialServiceTypes>

</SpecialServicesRequested>

<CustomsClearanceDetail>

<DutiesPayment>

<PaymentType>SENDER</PaymentType>

<Payor>

<ResponsibleParty>

<AccountNumber>604794161</AccountNumber>

<Contact>

<ContactId>12345</ContactId>

<PersonName>Input Your Information</PersonName>

</Contact>

</ResponsibleParty>

</Payor>

</DutiesPayment>

<DocumentContent>DOCUMENTS_ONLY</DocumentContent>

<CustomsValue>

<Currency>INR</Currency>

<Amount>100.00</Amount>

</CustomsValue>

<Commodities>

<NumberOfPieces>1</NumberOfPieces>

<Description>ABCD</Description>

<CountryOfManufacture>US</CountryOfManufacture>

<Weight>

<Units>LB</Units>

<Value>1.0</Value>

</Weight>

<Quantity>1</Quantity>

<QuantityUnits>cm</QuantityUnits>

<UnitPrice>

<Currency>INR</Currency>

<Amount>1.000000</Amount>

</UnitPrice>

<CustomsValue>

<Currency>INR</Currency>

<Amount>100.000000</Amount>

</CustomsValue>

</Commodities>

<ExportDetail>

<ExportComplianceStatement>30.37(f)</ExportComplianceStatement>

</ExportDetail>

</CustomsClearanceDetail>

<LabelSpecification>

<LabelFormatType>COMMON2D</LabelFormatType>

<ImageType>PNG</ImageType>

<LabelStockType>PAPER_7X4.75</LabelStockType>

</LabelSpecification>

<ShippingDocumentSpecification>

<ShippingDocumentTypes>COMMERCIAL_INVOICE</ShippingDocumentTypes>

<CommercialInvoiceDetail>

<Format>

<ImageType>PDF</ImageType>

<StockType>PAPER_LETTER</StockType>

<ProvideInstructions>1</ProvideInstructions>

</Format>

</CommercialInvoiceDetail>

</ShippingDocumentSpecification>

<RateRequestTypes>LIST</RateRequestTypes>

<PackageCount>1</PackageCount>

<RequestedPackageLineItems>

<SequenceNumber>1</SequenceNumber>

<Weight>

<Units>LB</Units>

<Value>20.0</Value>

</Weight>

<Dimensions>

<Length>12</Length>

<Width>12</Width>

<Height>12</Height>

<Units>IN</Units>

</Dimensions>

<CustomerReferences>

<CustomerReferenceType>CUSTOMER_REFERENCE</CustomerReferenceType>

<Value>TC001_01_PT1_ST01_PK01_SNDUS_RCPCA_POS</Value>

</CustomerReferences>

</RequestedPackageLineItems>

</RequestedShipment>

</ProcessShipmentRequest>

</SOAP-ENV:Body>

</SOAP-ENV:Envelope>

但低于输出 -

SimpleXMLElement 对象 ( [@attributes] => 数组 ( [xmlnsSOAPENV] => http//schemas.xmlsoap.org/soap/envelope/ )

[SOAPENVHeader] => SimpleXMLElement Object
    (
    )

[SOAPENVBody] => SimpleXMLElement Object
    (
        [ProcessShipmentReply] => SimpleXMLElement Object
            (
                [HighestSeverity] => ERROR
                [Notifications] => SimpleXMLElement Object
                    (
                        [Severity] => ERROR
                        [Source] => ship
                        [Code] => 2200
                        [Message] => Missing or Invalid Shipment purpose for Commercial Invoice
                        [LocalizedMessage] => Missing or Invalid Shipment purpose for Commercial Invoice
                    )

                [TransactionDetail] => SimpleXMLElement Object
                    (
                        [CustomerTransactionId] => 8787
                    )

                [Version] => SimpleXMLElement Object
                    (
                        [ServiceId] => ship
                        [Major] => 19
                        [Intermediate] => 0
                        [Minor] => 0
                    )

            )

    )

)

这个 api 有什么问题?请建议。或者,如果有人已经集成,请向我们提供代码 sn-p,我可以使用它来生成联邦快递跟踪号和运输标签。

【问题讨论】:

    标签: xml api fedex


    【解决方案1】:

    您应该立即更改您的 API 凭据。您只是将它们粘贴到此处供所有人查看。

    您缺少Purpose 标签:

    <CommercialInvoice>
      <Purpose>SOLD</Purpose>
    </CommercialInvoice>
    

    可能的值:

    • 礼物
    • 已售出
    • 未售出
    • 个人效果
    • REPAIR_AND_RETURN
    • 示例

    这是来自RocketShipIt(我是首席开发人员)的完整工作示例:

    <Envelope>
      <Body>
        <ProcessShipmentRequest>
          <WebAuthenticationDetail>
            <UserCredential>
              <Key></Key>
              <Password></Password>
            </UserCredential>
          </WebAuthenticationDetail>
          <ClientDetail>
            <AccountNumber></AccountNumber>
            <MeterNumber></MeterNumber>
          </ClientDetail>
          <Version>
            <ServiceId>ship</ServiceId>
            <Major>17</Major>
            <Intermediate>0</Intermediate>
            <Minor>0</Minor>
          </Version>
          <RequestedShipment>
            <ShipTimestamp>2017-07-29T07:52:19.692709183-07:00</ShipTimestamp>
            <DropoffType>REGULAR_PICKUP</DropoffType>
            <ServiceType>STANDARD_OVERNIGHT</ServiceType>
            <PackagingType>YOUR_PACKAGING</PackagingType>
            <TotalWeight>
              <Units>LB</Units>
              <Value>5</Value>
            </TotalWeight>
            <Shipper>
              <Contact>
                <PersonName>John Doe</PersonName>
                <CompanyName>John Doe</CompanyName>
                <PhoneNumber>1231231234</PhoneNumber>
              </Contact>
              <Address>
                <StreetLines>2000 Meadowvale Rd</StreetLines>
                <City>mumbai</City>
                <StateOrProvinceCode>MH</StateOrProvinceCode>
                <PostalCode>400037</PostalCode>
                <CountryCode>IN</CountryCode>
              </Address>
            </Shipper>
            <Recipient>
              <Contact>
                <PersonName>John Doe</PersonName>
                <PhoneNumber>1231231234</PhoneNumber>
              </Contact>
              <Address>
                <StreetLines>2300 Southern Blvd</StreetLines>
                <City>Mumbai</City>
                <StateOrProvinceCode>MH</StateOrProvinceCode>
                <PostalCode>400037</PostalCode>
                <CountryCode>IN</CountryCode>
              </Address>
            </Recipient>
            <ShippingChargesPayment>
              <PaymentType>SENDER</PaymentType>
              <Payor>
                <ResponsibleParty>
                  <AccountNumber></AccountNumber>
                  <Contact>
                    <CompanyName>John Doe</CompanyName>
                  </Contact>
                  <Address>
                    <CountryCode>US</CountryCode>
                  </Address>
                </ResponsibleParty>
              </Payor>
            </ShippingChargesPayment>
            <SpecialServicesRequested>
              <SpecialServiceTypes>COD</SpecialServiceTypes>
              <CodDetail>
                <CodCollectionAmount>
                  <Currency>INR</Currency>
                  <Amount>100</Amount>
                </CodCollectionAmount>
                <CollectionType>CASH</CollectionType>
              </CodDetail>
            </SpecialServicesRequested>
            <CustomsClearanceDetail>
              <DutiesPayment>
                <PaymentType>RECIPIENT</PaymentType>
              </DutiesPayment>
              <CustomsValue>
                <Currency>INR</Currency>
                <Amount>0</Amount>
              </CustomsValue>
              <CommercialInvoice>
                <Purpose>SOLD</Purpose>
              </CommercialInvoice>
              <Commodities>
                <NumberOfPieces>1</NumberOfPieces>
                <Description>My Description</Description>
                <CountryOfManufacture>US</CountryOfManufacture>
                <Weight>
                  <Units>LB</Units>
                  <Value>2.5</Value>
                </Weight>
                <Quantity>1</Quantity>
                <QuantityUnits>EA</QuantityUnits>
                <UnitPrice>
                  <Currency>INR</Currency>
                  <Amount>50</Amount>
                </UnitPrice>
              </Commodities>
            </CustomsClearanceDetail>
            <LabelSpecification>
              <LabelFormatType>COMMON2D</LabelFormatType>
              <ImageType>PNG</ImageType>
              <LabelStockType>PAPER_4X6</LabelStockType>
              <LabelPrintingOrientation>TOP_EDGE_OF_TEXT_FIRST</LabelPrintingOrientation>
            </LabelSpecification>
            <PackageCount>1</PackageCount>
            <RequestedPackageLineItems>
              <SequenceNumber>1</SequenceNumber>
              <GroupPackageCount>1</GroupPackageCount>
              <Weight>
                <Units>LB</Units>
                <Value>5</Value>
              </Weight>
              <Dimensions>
                <Length>1</Length>
                <Width>1</Width>
                <Height>1</Height>
                <Units>IN</Units>
              </Dimensions>
            </RequestedPackageLineItems>
          </RequestedShipment>
        </ProcessShipmentRequest>
      </Body>
    </Envelope>
    

    【讨论】:

    • 嗨 sanbornm,感谢您的反馈。但它仍然给我们一个错误。您能否为我们创建一个包含 curl 在内的完整代码的测试文件?这样我们就可以测试并且可能我们没有以正确的方式集成它?您的帮助深表感谢兄弟。
    【解决方案2】:

    实际上,您发送请求的结构有误。您应该在CustomsClearanceDetail 下添加CommercialInvoice。此错误是由于请求中的请求参数放置错误造成的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-04-02
      • 1970-01-01
      • 2011-05-15
      • 1970-01-01
      • 2017-05-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多