1 Reply Latest reply on Nov 2, 2011 8:35 AM by ZoXo

    Amazon API

    ZoXo

      Title

      Amazon API

      Your post

      Hello all:

      Here is a tidbit of info for anyone who is attempting to use Amazon's Seller Central XML features.  The following code will get the last order report being generated by Amazon when you have a seller account and you have your order reports set to generate XML automatically.  The setting I requested was 15 minutes ( the shortest interval ).  I am in no way an expert on PHP or the Amazon API and this post is more of an informative attempt to get feedback and hopefully move the process forward, as there is potential for this to miss orders if I cannot find a way to make sure that I am retrieving all orders.  My attempt to solve that issue was to schedule the script to run every 15 minutes from the server.  I built a standalone file to handle this, so all it does is run the PHP code to get the last generated amazon order and imports it to the FileMaker file (using a stylesheet that will be included at the end ).  The import step is set to update by matching the amazon order iD, so even if there are no new orders and the XML is of the last imported order, it will basically import the same info to itself.  Once a new report is generated, the new orders will then be imported.

      I named the PHP file 'amazon_sendrequest.php'.  I use the import records script step and call the php file through HTTP and call a stylesheet through HTTP as well.  For my setup I am using a Mac with Apache and have simply placed the two documents in the following directory - Library/Web Server/Documents/Amazon/       Of course I have Web Sharing enabled and the request you program into FileMaker will depend on what your server's IP address is.

      The stylesheet is still a work in progress, as the amazon XML examples do not represent all possible fields, so basically I have to wait for an order with a particular field to be generated before I can modify the stylesheet to correctly address it.  Also, repeated elements are separated by "|" and "!" and must be parsed later to correctly get line items and orders separated into your FileMaker file.  ( I invite anyone with XSL knowledge to point me in a better direction as to how they deal with repeated elements in an XML file. )  Also amazon did some strange (to me) setup with their XML, so that is also the reason I did it the way I did.

      My reason for sharing this is to bounce it off anyone who may be doing something similar, or to provide at least an elementary beginning point for anyone who needs to do this.  The main issue I am concerned about is whether this solution will catch all orders or will I have to figure out a way to parse each report ID that is returned and import one at a time.  The current PHP code only outputs the report corresponding to the value of the variable $i which is set to zero.  When I manually change this in the code to be 1, it returns the previous report and so on for each increment.  I'm hoping that the script timing will circumvent this issue, but I am not sure as to the results yet.  I plan to let it run for a week and assess the results.

      Here is the PHP code ( Thanks to a post found on the Amazon Seller Services forum by shop223: http://www.amazonsellercommunity.com/forums/message.jspa?messageID=2410105 )

      This code was modified a bit to suit my needs and of course you must have a seller account and have the following info to make this work:

      AWS Access Key ID, Marketplace, Merchant ID, and secret key ( all of which are given to sellers when they have an account )

      ---------------------------------------------------------------------

      <?php
      function amazon_sendrequest($request,$loc="") {
      $method = "GET";
      $uri = "/";

      $AWSAccessKeyId = "xxx";
      $Marketplace = "xxx";
      $Merchant = "xxx";
      $SecretKey = "xxx";
      $host = "mws.amazonservices.com";
      $request .= "&AWSAccessKeyId=$AWSAccessKeyId&Marketplace=$Marketplace&Merchant=$Merchant&Timestamp=".gmdate("Y-m-d\TH:i:s\Z")."&Version=2009-01-01&SignatureVersion=2&SignatureMethod=HmacSHA256";

      // Clean up and sort
      $request = explode('&',$request);

      foreach ($request as $key => $value) {
      $t = explode("=",$value);
      $params[$t[0]] = $t[1];
      }
      unset($request);

      ksort($params);

      foreach ($params as $param=>$value) {
      $param = str_replace("%7E", "~", rawurlencode($param));
      $value = str_replace("%7E", "~", rawurlencode($value));
      $canonicalized_query[] = $param."=".$value;
      }

      $canonicalized_query = implode("&", $canonicalized_query);

      // create the string to sign
      $string_to_sign = $method."\n".$host."\n".$uri."\n".$canonicalized_query;

      // calculate HMAC with SHA256 and base64-encoding
      $signature = base64_encode(hash_hmac("sha256", $string_to_sign, $SecretKey, True));

      // encode the signature for the request
      $signature = str_replace("%7E", "~", rawurlencode($signature));

      // create request
      $request = "https://".$host.$uri."?".$canonicalized_query."&Signature=".$signature;

      $ch = curl_init();
      curl_setopt($ch,CURLOPT_HEADER, 0);
      curl_setopt($ch,CURLOPT_USERAGENT,"AmazonQuery/1.0 (Language=Amazon)Content-Type:xml");
      curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
      curl_setopt($ch,CURLOPT_URL, $request);
      curl_setopt($ch,CURLOPT_ENCODING , "xml");

      $novaresponse = curl_exec($ch);
      curl_close($ch);

      return $novaresponse;
      }

      function amazon_getorders() {
      $request = "Action=RequestReport&ReportType=_GET_ORDERS_DATA_&StartDate=".gmdate("Y-m-d\TH:i:s\Z",time()-86400);
      $response = amazon_sendrequest($request);

      $request = "Action=GetReportList&ReportTypeList=_GET_ORDERS_DATA_&StartDate=".gmdate("Y-m-d\TH:i:s\Z",time()-86400);
      $response = amazon_sendrequest($request);
      ini_set ("zend.ze1_compatibility_mode", 0);
      $result = simplexml_load_string($response);

      for ($i=0;$i<count($result->GetReportListResult->ReportInfo);$i++) {
      if ($result->GetReportListResult->ReportInfo[$i]->ReportType == "_GET_ORDERS_DATA_") {
      $request = "Action=GetReport&ReportId=".$result->GetReportListResult->ReportInfo[$i]->ReportId;
      $response = amazon_sendrequest($request);
      break;
      }
      }
      echo ($response);
      }
      amazon_getorders();
      ?>

       

      ---------------------------------------------------------------------

      and here is the stylesheet

      ---------------------------------------------------------------------

       

      <?xml version="1.0" encoding="UTF-8" ?>
      <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
      <xsl:output indent="yes" method="xml"/>
      <xsl:template match="AmazonEnvelope">
      <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult">
      <ERRORCODE>0</ERRORCODE>
      <PRODUCT BUILD="06-11-2010" NAME="FileMaker Pro" VERSION="11.0v2"/>
      <DATABASE DATEFORMAT="M/d/yyyy" LAYOUT="" NAME="PaperPapers_db.fp7" RECORDS="{@count}" TIMEFORMAT="h:mm:ss a"/>

      <METADATA>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="AmazonOrderID" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="AmazonSessionID" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="OrderDate" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="OrderPostedDate" TYPE="TEXT"/>

      <!--CustomOrderInfo is a repeating element Max occurrences: 10
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Type" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Value" TYPE="NUMBER"/>
      -->

      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="BuyerEmailAddress" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="BuyerName" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="BuyerPhoneNumber" TYPE="TEXT"/>

      <!--Credit Card Info
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Issuer" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Tail" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="ExpirationDate" TYPE="TEXT"/>
      -->
      <!--Billing Info
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Address_BillingData" TYPE="TEXT"/>
      -->


      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="FulfillmentMethod" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="FulfillmentServiceLevel" TYPE="TEXT"/>

      <!--FulfillmentData
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Address_FulfillmentData" TYPE="TEXT"/>
      -->

      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Name" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="AddressFieldOne" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="AddressFieldTwo" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="City" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="StateOrRegion" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="PostalCode" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="CountryCode" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="PhoneNumber" TYPE="TEXT"/>

      <!--Item is a repeating element-->
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="AmazonOrderItemCode" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="SKU" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Title" TYPE="TEXT"/>

      <!--CustomizationInfo is an unbounded repeating element
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="CustomizationInfo" TYPE="TEXT"/>
      -->

      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Quantity" TYPE="NUMBER"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="ProductTaxCode" TYPE="TEXT"/>

      <!--ItemPrice Component is a repeating element-->
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Type_ItemPrice" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Amount_ItemPrice" TYPE="NUMBER"/>

      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Type_Fee" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Amount_Fee" TYPE="NUMBER"/>

      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="TaxLocationCode" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="City_TaxJurisdictions" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="County_TaxJurisdictions" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="State_TaxJurisdictions" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="District_TaxableAmounts" TYPE="NUMBER"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="City_TaxableAmounts" TYPE="NUMBER"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="County_TaxableAmounts" TYPE="NUMBER"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="State_TaxableAmounts" TYPE="NUMBER"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="District_NonTaxableAmounts" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="City_NonTaxableAmounts" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="County_NonTaxableAmounts" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="State_NonTaxableAmounts" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="District_ZeroRatedAmounts" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="City_ZeroRatedAmounts" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="County_ZeroRatedAmounts" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="State_ZeroRatedAmounts" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="District_TaxCollectedAmounts" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="City_TaxCollectedAmounts" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="County_TaxCollectedAmounts" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="State_TaxCollectedAmounts" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="District_TaxRates" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="City_TaxRates" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="County_TaxRates" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="State_TaxRates" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="PromotionClaimCode" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="MerchantPromotionID" TYPE="TEXT"/>

      <!--Promotion Component is a repeating element-->
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Type_Promotion" TYPE="TEXT"/>
      <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="Amount_Promotion" TYPE="TEXT"/>

      </METADATA>

      <RESULTSET FOUND="{@count}">
      <xsl:for-each select="Message/OrderReport">
      <ROW MODID="0" RECORDID="{position()}">

      <COL><DATA><xsl:value-of select="AmazonOrderID"/></DATA></COL>
      <COL><DATA><xsl:value-of select="AmazonSessionID"/></DATA></COL>
      <COL><DATA><xsl:value-of select="OrderDate"/></DATA></COL>
      <COL><DATA><xsl:value-of select="OrderPostedDate"/></DATA></COL>
      <COL><DATA><xsl:value-of select="BillingData/BuyerEmailAddress"/></DATA></COL>
      <COL><DATA><xsl:value-of select="BillingData/BuyerName"/></DATA></COL>
      <COL><DATA><xsl:value-of select="BillingData/BuyerPhoneNumber"/></DATA></COL>
      <COL><DATA><xsl:value-of select="FulfillmentData/FulfillmentMethod"/></DATA></COL>
      <COL><DATA><xsl:value-of select="FulfillmentData/FulfillmentServiceLevel"/></DATA></COL>
      <COL><DATA><xsl:value-of select="FulfillmentData/Address/Name"/></DATA></COL>
      <COL><DATA><xsl:value-of select="FulfillmentData/Address/AddressFieldOne"/></DATA></COL>
      <COL><DATA><xsl:value-of select="FulfillmentData/Address/AddressFieldTwo"/></DATA></COL>
      <COL><DATA><xsl:value-of select="FulfillmentData/Address/City"/></DATA></COL>
      <COL><DATA><xsl:value-of select="FulfillmentData/Address/StateOrRegion"/></DATA></COL>
      <COL><DATA><xsl:value-of select="FulfillmentData/Address/PostalCode"/></DATA></COL>
      <COL><DATA><xsl:value-of select="FulfillmentData/Address/CountryCode"/></DATA></COL>
      <COL><DATA><xsl:value-of select="FulfillmentData/Address/PhoneNumber"/></DATA></COL>

      <!--Item is a repeating element-->
      <COL><DATA><xsl:for-each select="Item">
      <xsl:value-of select="AmazonOrderItemCode"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item">
      <xsl:value-of select="SKU"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item">
      <xsl:value-of select="Title"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item">
      <xsl:value-of select="Quantity"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item">
      <xsl:value-of select="ProductTaxCode"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemPrice">
      <xsl:for-each select="Component">
      <xsl:value-of select="Type"/>
      <xsl:text>!</xsl:text>
      </xsl:for-each>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemPrice">
      <xsl:for-each select="Component">
      <xsl:value-of select="Amount"/>
      <xsl:text>!</xsl:text>
      </xsl:for-each>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>


      <COL><DATA><xsl:for-each select="Item/ItemFees/Fee">
      <xsl:value-of select="Type"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemFees/Fee">
      <xsl:value-of select="Amount"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxJurisdictions">
      <xsl:value-of select="TaxLocationCode"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxJurisdictions">
      <xsl:value-of select="City"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxJurisdictions">
      <xsl:value-of select="County"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxJurisdictions">
      <xsl:value-of select="State"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxableAmounts">
      <xsl:value-of select="District"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxableAmounts">
      <xsl:value-of select="City"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxableAmounts">
      <xsl:value-of select="County"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxableAmounts">
      <xsl:value-of select="State"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/NonTaxableAmounts">
      <xsl:value-of select="District"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/NonTaxableAmounts">
      <xsl:value-of select="City"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/NonTaxableAmounts">
      <xsl:value-of select="County"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/NonTaxableAmounts">
      <xsl:value-of select="State"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/ZeroRatedAmounts">
      <xsl:value-of select="District"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/ZeroRatedAmounts">
      <xsl:value-of select="City"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/ZeroRatedAmounts">
      <xsl:value-of select="County"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/ZeroRatedAmounts">
      <xsl:value-of select="State"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxCollectedAmounts">
      <xsl:value-of select="District"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxCollectedAmounts">
      <xsl:value-of select="City"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxCollectedAmounts">
      <xsl:value-of select="County"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxCollectedAmounts">
      <xsl:value-of select="State"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxRates">
      <xsl:value-of select="District"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxRates">
      <xsl:value-of select="City"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxRates">
      <xsl:value-of select="County"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/ItemTaxData/TaxRates">
      <xsl:value-of select="State"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/Promotion">
      <xsl:value-of select="PromotionClaimCode"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/Promotion">
      <xsl:value-of select="MerchantPromotionID"/>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <!--Promotion Component is a repeating element-->
      <COL><DATA><xsl:for-each select="Item/Promotion">
      <xsl:for-each select="Component">
      <xsl:value-of select="Type"/>
      <xsl:text>!</xsl:text>
      </xsl:for-each>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      <COL><DATA><xsl:for-each select="Item/Promotion">
      <xsl:for-each select="Component">
      <xsl:value-of select="Amount"/>
      <xsl:text>!</xsl:text>
      </xsl:for-each>
      <xsl:text>|</xsl:text>
      </xsl:for-each></DATA></COL>

      </ROW>
      </xsl:for-each>

      </RESULTSET>
      </FMPXMLRESULT>
      </xsl:template>
      </xsl:stylesheet>

        • 1. Re: Amazon API
          ZoXo

          Well, it has been running for a month and it has indeed missed some orders, so while this solution works 'sort of' I am now going to have

          to use the PHP code that Amazon provides to query for a report list and then choose which report to get.  This code simply returns the last

          report, and in some instances the last report is NOT an order report, which throws an error to the server (harmless).  The fact that it is

          missing some orders though makes it ultimately unusable.  My next task has been to build a feed submission to send order fulfillment

          data to amazon via a feed.  I have had to use FX.php to grab data out of FileMaker so I can setup the feed.  I have had a successful

          submission, but am still awaiting confirmation that it was accepted.  For some reason, there is a 3 hour delay from when an order is placed

          to when an order report is generated for it, and I'm not sure if it's a function of the code I used above, or whether that is standard practice

          for the API.  The documentation for amazon is cryptic at best, so you really have to be an expert to make sense of their requirements, so

          for now I continue with trial and error until I have success with the feed submission.