php - Amazon MWS GetLowestOfferListingsForASIN and SimpleXML Not Working -


here sample data trying use:

<?xml version="1.0"?> <getlowestofferlistingsforasinresponse xmlns="http://mws.amazonservices.com/schema/products/2011-10-01"> <getlowestofferlistingsforasinresult asin="b006dtxdmo" status="success">   <allofferlistingsconsidered>true</allofferlistingsconsidered>   <product xmlns="http://mws.amazonservices.com/schema/products/2011-10-01" xmlns:ns2="http://mws.amazonservices.com/schema/products/2011-10-01/default.xsd"> <identifiers>   <marketplaceasin>     <marketplaceid>atvpdkikx0der</marketplaceid>     <asin>b006dtxdmo</asin>   </marketplaceasin> </identifiers> <lowestofferlistings>   <lowestofferlisting>     <qualifiers>       <itemcondition>new</itemcondition>       <itemsubcondition>new</itemsubcondition>       <fulfillmentchannel>amazon</fulfillmentchannel>       <shipsdomestically>true</shipsdomestically>       <shippingtime>         <max>0-2 days</max>       </shippingtime>       <sellerpositivefeedbackrating>95-97%</sellerpositivefeedbackrating>     </qualifiers>     <numberofofferlistingsconsidered>2</numberofofferlistingsconsidered>     <sellerfeedbackcount>26486</sellerfeedbackcount>     <price>       <landedprice>         <currencycode>usd</currencycode>         <amount>24.99</amount>       </landedprice>       <listingprice>         <currencycode>usd</currencycode>         <amount>24.99</amount>       </listingprice>       <shipping>         <currencycode>usd</currencycode>         <amount>0.00</amount>       </shipping>     </price>     <multipleoffersatlowestprice>true</multipleoffersatlowestprice>   </lowestofferlisting>   <lowestofferlisting>     <qualifiers>       <itemcondition>new</itemcondition>       <itemsubcondition>new</itemsubcondition>       <fulfillmentchannel>merchant</fulfillmentchannel>       <shipsdomestically>true</shipsdomestically>       <shippingtime>         <max>0-2 days</max>       </shippingtime>       <sellerpositivefeedbackrating>95-97%</sellerpositivefeedbackrating>     </qualifiers>     <numberofofferlistingsconsidered>1</numberofofferlistingsconsidered>     <sellerfeedbackcount>26486</sellerfeedbackcount>     <price>       <landedprice>         <currencycode>usd</currencycode>         <amount>29.99</amount>       </landedprice>       <listingprice>         <currencycode>usd</currencycode>         <amount>29.99</amount>       </listingprice>       <shipping>         <currencycode>usd</currencycode>         <amount>0.00</amount>       </shipping>     </price>     <multipleoffersatlowestprice>false</multipleoffersatlowestprice>   </lowestofferlisting>   <lowestofferlisting>     <qualifiers>       <itemcondition>new</itemcondition>       <itemsubcondition>new</itemsubcondition>       <fulfillmentchannel>merchant</fulfillmentchannel>       <shipsdomestically>unknown</shipsdomestically>       <shippingtime>         <max>0-2 days</max>       </shippingtime>       <sellerpositivefeedbackrating>98-100%</sellerpositivefeedbackrating>     </qualifiers>     <numberofofferlistingsconsidered>1</numberofofferlistingsconsidered>     <sellerfeedbackcount>10398</sellerfeedbackcount>     <price>       <landedprice>         <currencycode>usd</currencycode>         <amount>198.99</amount>       </landedprice>       <listingprice>         <currencycode>usd</currencycode>         <amount>198.99</amount>       </listingprice>       <shipping>         <currencycode>usd</currencycode>         <amount>0.00</amount>       </shipping>     </price>     <multipleoffersatlowestprice>false</multipleoffersatlowestprice>   </lowestofferlisting>   <lowestofferlisting>     <qualifiers>       <itemcondition>new</itemcondition>       <itemsubcondition>new</itemsubcondition>       <fulfillmentchannel>merchant</fulfillmentchannel>       <shipsdomestically>true</shipsdomestically>       <shippingtime>         <max>3-7 days</max>       </shippingtime>       <sellerpositivefeedbackrating>98-100%</sellerpositivefeedbackrating>     </qualifiers>     <numberofofferlistingsconsidered>1</numberofofferlistingsconsidered>     <sellerfeedbackcount>1</sellerfeedbackcount>     <price>       <landedprice>         <currencycode>usd</currencycode>         <amount>589.49</amount>       </landedprice>       <listingprice>         <currencycode>usd</currencycode>         <amount>589.49</amount>       </listingprice>       <shipping>         <currencycode>usd</currencycode>         <amount>0.00</amount>       </shipping>     </price>     <multipleoffersatlowestprice>false</multipleoffersatlowestprice>   </lowestofferlisting> </lowestofferlistings>   </product> </getlowestofferlistingsforasinresult> <getlowestofferlistingsforasinresult asin="b00dl6it5s" status="success">   <allofferlistingsconsidered>false</allofferlistingsconsidered>   <product xmlns="http://mws.amazonservices.com/schema/products/2011-10-01" xmlns:ns2="http://mws.amazonservices.com/schema/products/2011-10-01/default.xsd"> <identifiers>   <marketplaceasin>     <marketplaceid>atvpdkikx0der</marketplaceid>     <asin>b00dl6it5s</asin>   </marketplaceasin> </identifiers> <lowestofferlistings/>  </product> </getlowestofferlistingsforasinresult> <getlowestofferlistingsforasinresult asin="b00dkkkp3y" status="success">   <allofferlistingsconsidered>true</allofferlistingsconsidered>  <product xmlns="http://mws.amazonservices.com/schema/products/2011-10-01" xmlns:ns2="http://mws.amazonservices.com/schema/products/2011-10-01/default.xsd"> <identifiers>   <marketplaceasin>     <marketplaceid>atvpdkikx0der</marketplaceid>     <asin>b00dkkkp3y</asin>   </marketplaceasin> </identifiers> <lowestofferlistings>   <lowestofferlisting>     <qualifiers>       <itemcondition>new</itemcondition>       <itemsubcondition>new</itemsubcondition>       <fulfillmentchannel>amazon</fulfillmentchannel>       <shipsdomestically>true</shipsdomestically>       <shippingtime>         <max>0-2 days</max>       </shippingtime>       <sellerpositivefeedbackrating>95-97%</sellerpositivefeedbackrating>     </qualifiers>     <numberofofferlistingsconsidered>1</numberofofferlistingsconsidered>     <sellerfeedbackcount>4324</sellerfeedbackcount>     <price>       <landedprice>         <currencycode>usd</currencycode>         <amount>51.95</amount>       </landedprice>       <listingprice>         <currencycode>usd</currencycode>         <amount>51.95</amount>       </listingprice>       <shipping>         <currencycode>usd</currencycode>         <amount>0.00</amount>       </shipping>     </price>     <multipleoffersatlowestprice>false</multipleoffersatlowestprice>   </lowestofferlisting> </lowestofferlistings>   </product> </getlowestofferlistingsforasinresult> <getlowestofferlistingsforasinresult asin="b00xap7wl2" status="success">   <allofferlistingsconsidered>false</allofferlistingsconsidered>  <product xmlns="http://mws.amazonservices.com/schema/products/2011-10-01" xmlns:ns2="http://mws.amazonservices.com/schema/products/2011-10-01/default.xsd"> <identifiers>   <marketplaceasin>     <marketplaceid>atvpdkikx0der</marketplaceid>     <asin>b00xap7wl2</asin>   </marketplaceasin> </identifiers> <lowestofferlistings/>   </product> </getlowestofferlistingsforasinresult> <getlowestofferlistingsforasinresult asin="b00waf736m" status="success">   <allofferlistingsconsidered>true</allofferlistingsconsidered>   <product xmlns="http://mws.amazonservices.com/schema/products/2011-10-01" xmlns:ns2="http://mws.amazonservices.com/schema/products/2011-10-01/default.xsd"> <identifiers>   <marketplaceasin>     <marketplaceid>atvpdkikx0der</marketplaceid>     <asin>b00waf736m</asin>   </marketplaceasin> </identifiers> <lowestofferlistings>   <lowestofferlisting>     <qualifiers>       <itemcondition>new</itemcondition>       <itemsubcondition>new</itemsubcondition>       <fulfillmentchannel>merchant</fulfillmentchannel>       <shipsdomestically>true</shipsdomestically>       <shippingtime>         <max>0-2 days</max>       </shippingtime>       <sellerpositivefeedbackrating>95-97%</sellerpositivefeedbackrating>     </qualifiers>     <numberofofferlistingsconsidered>1</numberofofferlistingsconsidered>     <sellerfeedbackcount>14457</sellerfeedbackcount>     <price>       <landedprice>         <currencycode>usd</currencycode>         <amount>39.99</amount>       </landedprice>       <listingprice>         <currencycode>usd</currencycode>         <amount>35.51</amount>       </listingprice>       <shipping>         <currencycode>usd</currencycode>         <amount>4.48</amount>       </shipping>     </price>     <multipleoffersatlowestprice>false</multipleoffersatlowestprice>   </lowestofferlisting> </lowestofferlistings>   </product> </getlowestofferlistingsforasinresult> <getlowestofferlistingsforasinresult asin="b0013uoshc" status="success">   <allofferlistingsconsidered>true</allofferlistingsconsidered>   <product xmlns="http://mws.amazonservices.com/schema/products/2011-10-01" xmlns:ns2="http://mws.amazonservices.com/schema/products/2011-10-01/default.xsd"> <identifiers>   <marketplaceasin>     <marketplaceid>atvpdkikx0der</marketplaceid>     <asin>b0013uoshc</asin>   </marketplaceasin> </identifiers> <lowestofferlistings/>  </product> </getlowestofferlistingsforasinresult> <getlowestofferlistingsforasinresult asin="b00szs9w4o" status="success">   <allofferlistingsconsidered>true</allofferlistingsconsidered>   <product xmlns="http://mws.amazonservices.com/schema/products/2011-10-01" xmlns:ns2="http://mws.amazonservices.com/schema/products/2011-10-01/default.xsd"> <identifiers>   <marketplaceasin>     <marketplaceid>atvpdkikx0der</marketplaceid>     <asin>b00szs9w4o</asin>   </marketplaceasin> </identifiers> <lowestofferlistings>   <lowestofferlisting>     <qualifiers>       <itemcondition>new</itemcondition>       <itemsubcondition>new</itemsubcondition>       <fulfillmentchannel>amazon</fulfillmentchannel>       <shipsdomestically>true</shipsdomestically>       <shippingtime>         <max>0-2 days</max>       </shippingtime>       <sellerpositivefeedbackrating>95-97%</sellerpositivefeedbackrating>     </qualifiers>     <numberofofferlistingsconsidered>1</numberofofferlistingsconsidered>     <sellerfeedbackcount>2748</sellerfeedbackcount>     <price>       <landedprice>         <currencycode>usd</currencycode>         <amount>19.99</amount>       </landedprice>       <listingprice>         <currencycode>usd</currencycode>         <amount>19.99</amount>       </listingprice>       <shipping>         <currencycode>usd</currencycode>         <amount>0.00</amount>       </shipping>     </price>     <multipleoffersatlowestprice>false</multipleoffersatlowestprice>   </lowestofferlisting>   <lowestofferlisting>     <qualifiers>       <itemcondition>new</itemcondition>       <itemsubcondition>new</itemsubcondition>       <fulfillmentchannel>merchant</fulfillmentchannel>       <shipsdomestically>true</shipsdomestically>       <shippingtime>         <max>0-2 days</max>       </shippingtime>       <sellerpositivefeedbackrating>95-97%</sellerpositivefeedbackrating>     </qualifiers>     <numberofofferlistingsconsidered>1</numberofofferlistingsconsidered>     <sellerfeedbackcount>2748</sellerfeedbackcount>     <price>       <landedprice>         <currencycode>usd</currencycode>         <amount>31.61</amount>       </landedprice>       <listingprice>         <currencycode>usd</currencycode>         <amount>25.99</amount>       </listingprice>       <shipping>         <currencycode>usd</currencycode>         <amount>5.62</amount>       </shipping>     </price>     <multipleoffersatlowestprice>false</multipleoffersatlowestprice>   </lowestofferlisting> </lowestofferlistings>   </product> </getlowestofferlistingsforasinresult>    <getlowestofferlistingsforasinresult asin="b00t0n0nnw" status="success">   <allofferlistingsconsidered>true</allofferlistingsconsidered>   <product xmlns="http://mws.amazonservices.com/schema/products/2011-10-01" xmlns:ns2="http://mws.amazonservices.com/schema/products/2011-10-01/default.xsd"> <identifiers>   <marketplaceasin>     <marketplaceid>atvpdkikx0der</marketplaceid>     <asin>b00t0n0nnw</asin>   </marketplaceasin> </identifiers> <lowestofferlistings>   <lowestofferlisting>     <qualifiers>       <itemcondition>new</itemcondition>       <itemsubcondition>new</itemsubcondition>       <fulfillmentchannel>amazon</fulfillmentchannel>       <shipsdomestically>true</shipsdomestically>       <shippingtime>         <max>0-2 days</max>       </shippingtime>       <sellerpositivefeedbackrating>95-97%</sellerpositivefeedbackrating>     </qualifiers>     <numberofofferlistingsconsidered>1</numberofofferlistingsconsidered>     <sellerfeedbackcount>2748</sellerfeedbackcount>     <price>       <landedprice>         <currencycode>usd</currencycode>         <amount>19.99</amount>       </landedprice>       <listingprice>         <currencycode>usd</currencycode>         <amount>19.99</amount>       </listingprice>       <shipping>         <currencycode>usd</currencycode>         <amount>0.00</amount>       </shipping>     </price>     <multipleoffersatlowestprice>false</multipleoffersatlowestprice>   </lowestofferlisting> </lowestofferlistings>  </product> </getlowestofferlistingsforasinresult> <getlowestofferlistingsforasinresult asin="b00f01v9rc" status="success">  <allofferlistingsconsidered>true</allofferlistingsconsidered>   <product xmlns="http://mws.amazonservices.com/schema/products/2011-10-01" xmlns:ns2="http://mws.amazonservices.com/schema/products/2011-10-01/default.xsd"> <identifiers>   <marketplaceasin>     <marketplaceid>atvpdkikx0der</marketplaceid>     <asin>b00f01v9rc</asin>   </marketplaceasin> </identifiers> <lowestofferlistings>   <lowestofferlisting>     <qualifiers>       <itemcondition>new</itemcondition>       <itemsubcondition>new</itemsubcondition>       <fulfillmentchannel>merchant</fulfillmentchannel>       <shipsdomestically>true</shipsdomestically>       <shippingtime>         <max>0-2 days</max>       </shippingtime>       <sellerpositivefeedbackrating>95-97%</sellerpositivefeedbackrating>     </qualifiers>     <numberofofferlistingsconsidered>1</numberofofferlistingsconsidered>     <sellerfeedbackcount>2191</sellerfeedbackcount>     <price>       <landedprice>         <currencycode>usd</currencycode>         <amount>19.50</amount>       </landedprice>       <listingprice>         <currencycode>usd</currencycode>         <amount>14.00</amount>       </listingprice>       <shipping>         <currencycode>usd</currencycode>         <amount>5.50</amount>       </shipping>     </price>     <multipleoffersatlowestprice>false</multipleoffersatlowestprice>   </lowestofferlisting>    </lowestofferlistings>  </product> </getlowestofferlistingsforasinresult> <responsemetadata>   <requestid>b5cb6d0f-14da-404b-af3d-f187877ea58e</requestid> </responsemetadata> </getlowestofferlistingsforasinresponse>'; 

here code:

            $param = array();             $param['awsaccesskeyid']    = 'access_key';              $param['action']            = 'getlowestofferlistingsforasin';             $param['sellerid']          = 'seller_id';              $param['signaturemethod']   = 'hmacsha256';               $param['signatureversion']  = '2';              $param['timestamp']         = gmdate("y-m-d\th:i:s.\\0\\0\\0\\z", time());             $param['version']           = '2011-10-01';              $param['marketplaceid']     = 'atvpdkikx0der';             $param['itemcondition']     = 'new';              //get variations (limit 9)             $inc=1;             foreach($variations $key=>$asin){                 if($inc <= 9){$param['asinlist.asin.' . $inc] = $asin;}                 $inc++;             }              $secret = 'secret';              $url = array();             foreach ($param $key => $val) {                 $key = str_replace("%7e", "~", rawurlencode($key));                 $val = str_replace("%7e", "~", rawurlencode($val));                 $url[] = "{$key}={$val}";             }              sort($url);              $arr   = implode('&', $url);              $sign  = 'get' . "\n";             $sign .= 'mws.amazonservices.com' . "\n";             $sign .= '/products/2011-10-01' . "\n";             $sign .= $arr;              $signature = hash_hmac("sha256", $sign, $secret, true);             $signature = urlencode(base64_encode($signature));              $link  = "https://mws.amazonservices.com/products/2011-10-01?";             $link .= $arr . "&signature=" . $signature;              $ch = curl_init($link);             curl_setopt($ch, curlopt_httpheader, array('content-type: application/xml'));             curl_setopt($ch, curlopt_returntransfer, true);             curl_setopt($ch, curlopt_ssl_verifypeer, false);              $response = curl_exec($ch);             $info = curl_getinfo($ch);             curl_close($ch);  $response = preg_replace('/&(?!#?[a-z0-9]+;)/', '&amp;', $response); $price_data = simplexml_load_string($response);  $node = $price_data->getlowestofferlistingsforasinresult->product; foreach($node $product){     $asin = $product->identifiers->marketplaceasin->asin;      $node = $product->lowestofferlistings->lowestofferlisting->price->landedprice;     foreach($node $price){         $amzn_price = $price->amount;     }      echo "$asin $amzn_price <br />"; } 

i using similar code listmatchingproducts. trying loop through results match lowest prices asin, gives me first result instead of results. have tried using children , other things can think of, still no luck.

have @ code below if helps:

$response = $service->getlowestofferlistingsforasin($request);  $dom = new domdocument(); $dom->loadxml($response->toxml()); $dom->preservewhitespace = false; $dom->formatoutput = true; $xml_data = $dom->savexml(); $dom->loadxml($xml_data);  $otherofferxml = simplexml_load_string($xml_data);  foreach($otherofferxml $offers) {     // skipping last requestid section     if(!isset($offers["status"]))         continue;      // checking if api returned error continue next sku     if($offers["status"] != "success")         continue;      $asin = (string) $offers->product->identifiers->marketplaceasin->asin;      // going through asin's offers price     $seller_counter = 0;     $others_response_data[$asin] = "";     foreach($offers->product->lowestofferlistings->lowestofferlisting $offers_list)     {         $others_response_data[$asin][$seller_counter]["landedprice"] = (string) $offers_list->price->landedprice->amount;         $others_response_data[$asin][$seller_counter]["listingprice"] = (string) $offers_list->price->listingprice->amount;         $others_response_data[$asin][$seller_counter]["shipping"] = (string) $offers_list->price->shipping->amount;         $others_response_data[$asin][$seller_counter]["fulfillment"] = $fulfillment_channel;         $others_response_data[$asin][$seller_counter]["sku"] = $asin_array[$asin]["sku"];         $others_response_data[$asin][$seller_counter]["azn_asin"] = $asin;         $seller_counter++;       } } 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -