You are here:  » amazon products not show up


amazon products not show up

Submitted by komrad on Mon, 2017-03-13 15:14 in

Hello David,

Could you tell me why amazon products not show up on my site {link saved}

Cheers,
Asep

Submitted by support on Mon, 2017-03-13 15:36

Hello Asep,

I see that you are using the original inline Amazon API module (amazon.php) - you might wish to consider replacing that with the newer Asynchronous Amazon and eBay API Modules version which will show Amazon results in a tab alongside the search results and therefore not slow your page load time down at all.

If you decide to go ahead with the conversion, there are debug instructions for when an API module does not return any results in this comment.

However, if you would prefer to continue using your existing version, to modify amazon.php to generate the same debug output, look for the following code at line 165:

    MagicParser_parse($url,"myAmazonRecordHandler","xml|ITEMSEARCHRESPONSE/ITEMS/ITEM/");

...and REPLACE with:

    $xml = file_get_contents($url);
    if (isset($_GET["debug"]))
    {
      print "<textarea style='width:100%;height:300px;'>".htmlspecialchars($mml,ENT_QUOTES,$config_charset)."</textarea>";
    }
    MagicParser_parse("string://".$xml,"myAmazonRecordHandler","xml|ITEMSEARCHRESPONSE/ITEMS/ITEM/");

With that in place, view a search results page with ?debug=1 in the URL e.g.

http://www.example.com/search.php?q=iphone&debug=1

The API response should then be displayed in a textarea below the search results. Amazon API error messages normally indicate the problem but if you are not sure from what is displayed (or if the textarea is empty) where the problem lies let me know what is displayed and I'll check it out further with you...

Cheers,
David.
--
PriceTapestry.com

Submitted by komrad on Mon, 2017-03-13 16:07

the textarea is empty im afraid. could you help

Submitted by support on Mon, 2017-03-13 16:29

Hello Asep,

That could indicate that URL Wrappers are disabled on your PHP installation. More details on that setting (allow_url_fopen) here:

http://php.net/manual/en/filesystem.configuration.php#ini.allow-url-fopen

However, it is increasingly common for CURL to be installed which can be used instead. To modify the API calling code to use CURL instead, edit amazon.php and where you now have the following code at line 165:

    $xml = file_get_contents($url);

...REPLACE with;

    $ch = curl_init($url);
    curl_setopt($ch, CURLOPT_HEADER, 0 );
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $xml = curl_exec($ch);

Hope this helps!

Cheers,
David.
--
PriceTapestry.com

Submitted by komrad on Mon, 2017-03-13 16:58

It works now. I'm using CURL. Thanks again!