dsfs5420 2016-02-24 10:52 采纳率: 100%
浏览 52
已采纳

如何在PHP中使用API​​从亚马逊获得蜡烛订单

I need to get all the order of Cancellations / Refunds / Returns using amazon API i am alreday get all the order but any one sugest me how can i get these order too.

  • 写回答

1条回答 默认 最新

  • doufei3561 2016-02-24 13:23
    关注
    <?php
    /** 
     *  PHP Version 5
     *
     *  @category    Amazon
     *  @package     MarketplaceWebServiceOrders
     *  @copyright   Copyright 2008-2009 Amazon.com, Inc. or its affiliates. All Rights Reserved.
     *  @link        http://aws.amazon.com
     *  @license     http://aws.amazon.com/apache2.0  Apache License, Version 2.0
     *  @version     2011-01-01
     */
    /******************************************************************************* 
     *  Marketplace Web Service Orders PHP5 Library
     *  Generated: Fri Jan 21 18:53:17 UTC 2011
     * 
     */
    
    /**
     * List Orders  Sample
     */
    
    include_once ('config.inc.php'); 
    
     $config = array (
       'ServiceURL' => MWS_ENDPOINT_Orders_URL,
       'ProxyHost' => null,
       'ProxyPort' => -1,
       'MaxErrorRetry' => 3,
     );
     $service = new MarketplaceWebServiceOrders_Client(
            AWS_ACCESS_KEY_ID,
            AWS_SECRET_ACCESS_KEY,
            APPLICATION_NAME,
            APPLICATION_VERSION,
            $config);
    
    /************************************************************************
     * Setup request parameters and uncomment invoke to try out 
     * sample for List Orders Action
     ***********************************************************************/
     $request = new MarketplaceWebServiceOrders_Model_ListOrdersRequest();
     $request->setSellerId(MERCHANT_ID);
    
     // List all orders udpated after a certain date
     $request->setCreatedAfter(new DateTime('2010-01-01 12:00:00', new DateTimeZone('UTC')));
    
     // Set the marketplaces queried in this ListOrdersRequest
     $marketplaceIdList = new MarketplaceWebServiceOrders_Model_MarketplaceIdList();
     $marketplaceIdList->setId(array(MARKETPLACE_ID));
    
     $request->setMarketplaceId($marketplaceIdList);
    
    // echo '<pre>'; print_r($marketplaceIdList);
    
     // Set the order statuses for this ListOrdersRequest (optional)
       $orderStatuses = new MarketplaceWebServiceOrders_Model_OrderStatusList();
     $orderStatuses->setStatus(array('Shipped'));
    $x= $request->setOrderStatus($orderStatuses);
    
    print_r($x);
    
     // Set the Fulfillment Channel for this ListOrdersRequest (optional)
      $fulfillmentChannels = new MarketplaceWebServiceOrders_Model_FulfillmentChannelList();
      $fulfillmentChannels->setChannel(array('MFN'));
      $request->setFulfillmentChannel($fulfillmentChannels);
    
     // @TODO: set request. Action can be passed as MarketplaceWebServiceOrders_Model_ListOrdersRequest
     // object or array of parameters
     invokeListOrders($service, $request);
    
    
    /**
      * List Orders Action Sample
      * ListOrders can be used to find orders that meet the specified criteria.
      *   
      * @param MarketplaceWebServiceOrders_Interface $service instance of MarketplaceWebServiceOrders_Interface
      * @param mixed $request MarketplaceWebServiceOrders_Model_ListOrders or array of parameters
      */
      function invokeListOrders(MarketplaceWebServiceOrders_Interface $service, $request) 
      {
          try {
                  $response = $service->listOrders($request);
                echo '<pre>';  print_r($response);
                    echo ("Service Response
    ");
                    echo ("=============================================================================
    ");
    
                    echo("        ListOrdersResponse
    ");
                    if ($response->isSetListOrdersResult()) { 
                        echo("            ListOrdersResult
    ");
                        $listOrdersResult = $response->getListOrdersResult();
                        if ($listOrdersResult->isSetNextToken()) 
                        {
                            echo("                NextToken
    ");
                            echo("                    " . $listOrdersResult->getNextToken() . "
    ");
                        }
                        if ($listOrdersResult->isSetCreatedBefore()) 
                        {
                            echo("                CreatedBefore
    ");
                            echo("                    " . $listOrdersResult->getCreatedBefore() . "
    ");
                        }
                        if ($listOrdersResult->isSetLastUpdatedBefore()) 
                        {
                            echo("                LastUpdatedBefore
    ");
                            echo("                    " . $listOrdersResult->getLastUpdatedBefore() . "
    ");
                        }
                        if ($listOrdersResult->isSetOrders()) { 
                            echo("                Orders
    ");
                            $orders = $listOrdersResult->getOrders();
                            $orderList = $orders->getOrder();
                            foreach ($orderList as $order) {
                                echo("                    Order
    ");
                                if ($order->isSetAmazonOrderId()) 
                                {
                                    echo("                        AmazonOrderId
    ");
                                    echo("                            " . $order->getAmazonOrderId() . "
    ");
                                }
                                if ($order->isSetSellerOrderId()) 
                                {
                                    echo("                        SellerOrderId
    ");
                                    echo("                            " . $order->getSellerOrderId() . "
    ");
                                }
                                if ($order->isSetPurchaseDate()) 
                                {
                                    echo("                        PurchaseDate
    ");
                                    echo("                            " . $order->getPurchaseDate() . "
    ");
                                }
                                if ($order->isSetLastUpdateDate()) 
                                {
                                    echo("                        LastUpdateDate
    ");
                                    echo("                            " . $order->getLastUpdateDate() . "
    ");
                                }
                                if ($order->isSetOrderStatus()) 
                                {
                                    echo("                        OrderStatus
    ");
                                    echo("                            " . $order->getOrderStatus() . "
    ");
                                }
                                if ($order->isSetFulfillmentChannel()) 
                                {
                                    echo("                        FulfillmentChannel
    ");
                                    echo("                            " . $order->getFulfillmentChannel() . "
    ");
                                }
                                if ($order->isSetSalesChannel()) 
                                {
                                    echo("                        SalesChannel
    ");
                                    echo("                            " . $order->getSalesChannel() . "
    ");
                                }
                                if ($order->isSetOrderChannel()) 
                                {
                                    echo("                        OrderChannel
    ");
                                    echo("                            " . $order->getOrderChannel() . "
    ");
                                }
                                if ($order->isSetShipServiceLevel()) 
                                {
                                    echo("                        ShipServiceLevel
    ");
                                    echo("                            " . $order->getShipServiceLevel() . "
    ");
                                }
                                if ($order->isSetShippingAddress()) { 
                                    echo("                        ShippingAddress
    ");
                                    $shippingAddress = $order->getShippingAddress();
                                    if ($shippingAddress->isSetName()) 
                                    {
                                        echo("                            Name
    ");
                                        echo("                                " . $shippingAddress->getName() . "
    ");
                                    }
                                    if ($shippingAddress->isSetAddressLine1()) 
                                    {
                                        echo("                            AddressLine1
    ");
                                        echo("                                " . $shippingAddress->getAddressLine1() . "
    ");
                                    }
                                    if ($shippingAddress->isSetAddressLine2()) 
                                    {
                                        echo("                            AddressLine2
    ");
                                        echo("                                " . $shippingAddress->getAddressLine2() . "
    ");
                                    }
                                    if ($shippingAddress->isSetAddressLine3()) 
                                    {
                                        echo("                            AddressLine3
    ");
                                        echo("                                " . $shippingAddress->getAddressLine3() . "
    ");
                                    }
                                    if ($shippingAddress->isSetCity()) 
                                    {
                                        echo("                            City
    ");
                                        echo("                                " . $shippingAddress->getCity() . "
    ");
                                    }
                                    if ($shippingAddress->isSetCounty()) 
                                    {
                                        echo("                            County
    ");
                                        echo("                                " . $shippingAddress->getCounty() . "
    ");
                                    }
                                    if ($shippingAddress->isSetDistrict()) 
                                    {
                                        echo("                            District
    ");
                                        echo("                                " . $shippingAddress->getDistrict() . "
    ");
                                    }
                                    if ($shippingAddress->isSetStateOrRegion()) 
                                    {
                                        echo("                            StateOrRegion
    ");
                                        echo("                                " . $shippingAddress->getStateOrRegion() . "
    ");
                                    }
                                    if ($shippingAddress->isSetPostalCode()) 
                                    {
                                        echo("                            PostalCode
    ");
                                        echo("                                " . $shippingAddress->getPostalCode() . "
    ");
                                    }
                                    if ($shippingAddress->isSetCountryCode()) 
                                    {
                                        echo("                            CountryCode
    ");
                                        echo("                                " . $shippingAddress->getCountryCode() . "
    ");
                                    }
                                    if ($shippingAddress->isSetPhone()) 
                                    {
                                        echo("                            Phone
    ");
                                        echo("                                " . $shippingAddress->getPhone() . "
    ");
                                    }
                                } 
                                if ($order->isSetOrderTotal()) { 
                                    echo("                        OrderTotal
    ");
                                    $orderTotal = $order->getOrderTotal();
                                    if ($orderTotal->isSetCurrencyCode()) 
                                    {
                                        echo("                            CurrencyCode
    ");
                                        echo("                                " . $orderTotal->getCurrencyCode() . "
    ");
                                    }
                                    if ($orderTotal->isSetAmount()) 
                                    {
                                        echo("                            Amount
    ");
                                        echo("                                " . $orderTotal->getAmount() . "
    ");
                                    }
                                } 
                                if ($order->isSetNumberOfItemsShipped()) 
                                {
                                    echo("                        NumberOfItemsShipped
    ");
                                    echo("                            " . $order->getNumberOfItemsShipped() . "
    ");
                                }
                                if ($order->isSetNumberOfItemsUnshipped()) 
                                {
                                    echo("                        NumberOfItemsUnshipped
    ");
                                    echo("                            " . $order->getNumberOfItemsUnshipped() . "
    ");
                                }
                                if ($order->isSetMarketplaceId()) 
                                {
                                    echo("                        MarketplaceId
    ");
                                    echo("                            " . $order->getMarketplaceId() . "
    ");
                                }
                                if ($order->isSetBuyerEmail()) 
                                {
                                    echo("                        BuyerEmail
    ");
                                    echo("                            " . $order->getBuyerEmail() . "
    ");
                                }
                                if ($order->isSetBuyerName()) 
                                {
                                    echo("                        BuyerName
    ");
                                    echo("                            " . $order->getBuyerName() . "
    ");
                                }
                                if ($order->isSetShipmentServiceLevelCategory()) 
                                {
                                    echo("                        ShipmentServiceLevelCategory
    ");
                                    echo("                            " . $order->getShipmentServiceLevelCategory() . "
    ");
                                }
                            }
                        } 
                    } 
                    if ($response->isSetResponseMetadata()) { 
                        echo("            ResponseMetadata
    ");
                        $responseMetadata = $response->getResponseMetadata();
                        if ($responseMetadata->isSetRequestId()) 
                        {
                            echo("                RequestId
    ");
                            echo("                    " . $responseMetadata->getRequestId() . "
    ");
                        }
                    } 
    
         } catch (MarketplaceWebServiceOrders_Exception $ex) {
             echo("Caught Exception: " . $ex->getMessage() . "
    ");
             echo("Response Status Code: " . $ex->getStatusCode() . "
    ");
             echo("Error Code: " . $ex->getErrorCode() . "
    ");
             echo("Error Type: " . $ex->getErrorType() . "
    ");
             echo("Request ID: " . $ex->getRequestId() . "
    ");
             echo("XML: " . $ex->getXML() . "
    ");
         }
     }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥170 如图所示配置eNSP
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装