Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2019
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.12 KB | None | 0 0
  1. <?php
  2. /**
  3.  *  PHP Version 5
  4.  *
  5.  *  @category    Amazon
  6.  *  @package     MarketplaceWebService
  7.  *  @copyright   Copyright 2009 Amazon Technologies, Inc.
  8.  *  @link        http://aws.amazon.com
  9.  *  @license     http://aws.amazon.com/apache2.0  Apache License, Version 2.0
  10.  *  @version     2009-01-01
  11.  */
  12. /*******************************************************************************
  13.  
  14.  *  Marketplace Web Service PHP5 Library
  15.  *  Generated: Thu May 07 13:07:36 PDT 2009
  16.  *
  17.  */
  18.  
  19. /**
  20.  * Get Feed Submission Result  Sample
  21.  */
  22.  
  23. require_once(dirname(__FILE__)."/.config.inc.php");
  24.  
  25. /************************************************************************
  26. * Uncomment to configure the client instance. Configuration settings
  27. * are:
  28. *
  29. * - MWS endpoint URL
  30. * - Proxy host and port.
  31. * - MaxErrorRetry.
  32. ***********************************************************************/
  33. // IMPORTANT: Uncomment the appropriate line for the country you wish to
  34. // sell in:
  35. // United States:
  36. $serviceUrl = "https://mws.amazonservices.com";
  37. // United Kingdom
  38. //$serviceUrl = "https://mws.amazonservices.co.uk";
  39. // Germany
  40. //$serviceUrl = "https://mws.amazonservices.de";
  41. // France
  42. //$serviceUrl = "https://mws.amazonservices.fr";
  43. // Italy
  44. //$serviceUrl = "https://mws.amazonservices.it";
  45. // Japan
  46. //$serviceUrl = "https://mws.amazonservices.jp";
  47. // China
  48. //$serviceUrl = "https://mws.amazonservices.com.cn";
  49. // Canada
  50. //$serviceUrl = "https://mws.amazonservices.ca";
  51. // India
  52. //$serviceUrl = "https://mws.amazonservices.in";
  53.  
  54. /************************************************************************
  55.  * Instantiate Implementation of MarketplaceWebService
  56.  *
  57.  * AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY constants
  58.  * are defined in the .config.inc.php located in the same
  59.  * directory as this sample
  60.  ***********************************************************************/
  61.  
  62. /************************************************************************
  63.  * Uncomment to try out Mock Service that simulates MarketplaceWebService
  64.  * responses without calling MarketplaceWebService service.
  65.  *
  66.  * Responses are loaded from local XML files. You can tweak XML files to
  67.  * experiment with various outputs during development
  68.  *
  69.  * XML files available under MarketplaceWebService/Mock tree
  70.  *
  71.  ***********************************************************************/
  72.   //$service = new MarketplaceWebService_Mock();
  73.  
  74. /************************************************************************
  75.  * Setup request parameters and uncomment invoke to try out
  76.  * sample for Get Feed Submission Result Action
  77.  ***********************************************************************/
  78.  // @TODO: set request. Action can be passed as MarketplaceWebService_Model_GetFeedSubmissionResultRequest
  79.  // object or array of parameters
  80.  
  81. $MWSAuthToken = "";
  82. $Merchant_Id = "";
  83. $parameters = array (
  84.   'Merchant' => $Merchant_Id,
  85.   'FeedSubmissionId' => $FeedId,
  86.   'FeedSubmissionResult' => @fopen('php://memory', 'rw+')
  87. );
  88.  
  89.   $config = array (
  90.     'ServiceURL' => $serviceUrl,
  91.     'ProxyHost' => null,
  92.     'ProxyPort' => -1,
  93.     'MaxErrorRetry' => 3,
  94.   );
  95. $service = new MarketplaceWebService_Client(
  96.   AWS_ACCESS_KEY_ID,
  97.   AWS_SECRET_ACCESS_KEY,
  98.   $config,
  99.   APPLICATION_NAME,
  100.   APPLICATION_VERSION);
  101.    
  102.   /**************
  103.      FEED CHECK
  104.   ***************/
  105.   echo "feed check\n";
  106.    
  107.     $request = new MarketplaceWebService_Model_GetFeedSubmissionResultRequest();
  108.     $request->setMerchant($Merchant_Id);
  109.     if($MWSAuthToken) {
  110.       $request->setMWSAuthToken($MWSAuthToken);
  111.     }
  112.     $request->setFeedSubmissionId($FeedId);
  113.     $fileHandle = fopen('php://memory', 'rw+');
  114.     $request->setFeedSubmissionResult($fileHandle);
  115.    
  116.     try {
  117.       $response = $service->getFeedSubmissionResult($request);
  118.       rewind($fileHandle);
  119.       $getResponse = stream_get_contents($fileHandle);
  120.       $responseDoc = new SimpleXMLElement($getResponse);
  121.       $StatusCode = (isset($responseDoc->Message->ProcessingReport->StatusCode) ? $responseDoc->Message->ProcessingReport->StatusCode : "");
  122.       $NumProcessed = (isset($responseDoc->Message->ProcessingReport->ProcessingSummary->MessagesProcessed) ? $responseDoc->Message->ProcessingReport->ProcessingSummary->MessagesProcessed : 0);
  123.       $NumErrors = (isset($responseDoc->Message->ProcessingReport->ProcessingSummary->MessagesWithError) ? $responseDoc->Message->ProcessingReport->ProcessingSummary->MessagesWithError : 0);
  124.    
  125.       echo "Status: $StatusCode<br />Processed: $NumProcessed - Errors: $NumErrors";
  126.       $i = 0;
  127.       $Msg = "";
  128.       $MaxLoopCount = 100;
  129.       foreach($responseDoc->Message->ProcessingReport->Result as $key) {
  130.        
  131.         $Type = $responseDoc->Message->ProcessingReport->Result[$i]->ResultCode;
  132.         $ErrorCode = $responseDoc->Message->ProcessingReport->Result[$i]->ResultMessageCode;
  133.         $Message = $responseDoc->Message->ProcessingReport->Result[$i]->ResultDescription;
  134.         if(strtolower(trim($Type)) == "error") {
  135.           $Msg .= "$Type : $ErrorCode<br />$Message<br />";
  136.         }
  137.         $i++;
  138.         if($i > $MaxLoopCount) {
  139.           break;
  140.         }
  141.       }
  142.       echo $Msg;
  143.      
  144.  
  145.     } catch (MarketplaceWebService_Exception $ex) {
  146.       echo "Error: $ex";
  147.       $ErrorMsg = $ex->getMessage();
  148.  
  149.     }
  150.  
  151.  
  152.  
  153.  
  154. $request = new MarketplaceWebService_Model_GetFeedSubmissionResultRequest($parameters);
  155.  
  156. $request = new MarketplaceWebService_Model_GetFeedSubmissionResultRequest();
  157. $request->setMerchant($Merchant_Id);
  158. if($MWSAuthToken) {
  159.   $request->setMWSAuthToken($MWSAuthToken);
  160. }
  161. $request->setFeedSubmissionId($FeedId);
  162. $request->setFeedSubmissionResult(@fopen('php://memory', 'rw+'));
  163.  
  164.      
  165. invokeGetFeedSubmissionResult($service, $request);
  166.  
  167. /**
  168.   * Get Feed Submission Result Action Sample
  169.   * retrieves the feed processing report
  170.   *  
  171.   * @param MarketplaceWebService_Interface $service instance of MarketplaceWebService_Interface
  172.   * @param mixed $request MarketplaceWebService_Model_GetFeedSubmissionResult or array of parameters
  173.   */
  174.   function invokeGetFeedSubmissionResult(MarketplaceWebService_Interface $service, $request)
  175.   {
  176.       try {
  177.               $response = $service->getFeedSubmissionResult($request);
  178.               print_r($response);
  179.                 echo ("Service Response\n");
  180.                 echo ("=============================================================================\n");
  181.  
  182.                 echo("        GetFeedSubmissionResultResponse\n");
  183.                 if ($response->isSetGetFeedSubmissionResultResult()) {
  184.                   $getFeedSubmissionResultResult = $response->getGetFeedSubmissionResultResult();
  185.                   echo ("            GetFeedSubmissionResult");
  186.                  
  187.                   if ($getFeedSubmissionResultResult->isSetContentMd5()) {
  188.                     echo ("                ContentMd5");
  189.                     echo ("                " . $getFeedSubmissionResultResult->getContentMd5() . "\n");
  190.                   }
  191.                 }
  192.                 if ($response->isSetResponseMetadata()) {
  193.                     echo("            ResponseMetadata\n");
  194.                     $responseMetadata = $response->getResponseMetadata();
  195.                     if ($responseMetadata->isSetRequestId())
  196.                     {
  197.                         echo("                RequestId\n");
  198.                         echo("                    " . $responseMetadata->getRequestId() . "\n");
  199.                     }
  200.                 }
  201.  
  202.                 echo("            ResponseHeaderMetadata: " . $response->getResponseHeaderMetadata() . "\n");
  203.      } catch (MarketplaceWebService_Exception $ex) {
  204.          echo("Caught Exception: " . $ex->getMessage() . "\n");
  205.          echo("Response Status Code: " . $ex->getStatusCode() . "\n");
  206.          echo("Error Code: " . $ex->getErrorCode() . "\n");
  207.          echo("Error Type: " . $ex->getErrorType() . "\n");
  208.          echo("Request ID: " . $ex->getRequestId() . "\n");
  209.          echo("XML: " . $ex->getXML() . "\n");
  210.          echo("ResponseHeaderMetadata: " . $ex->getResponseHeaderMetadata() . "\n");
  211.      }
  212.  }
  213. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement