Hello,

First of all I would like to thank you for such a great module. I have been using it for several websites, but recently I faced a problem. This time I am using function calls in page.tpl.php file. Here is the function call:

$asin    = _amazon_clean_type($account->profile_isbn);
$_amazon = amazon_item_lookup($asin);
$amazon  = $_amazon[$asin];

The code provides correct result for most ISBNs, but for some it doesn't, for example: 286325507X ISBN provides no value. For displaying data in amazon array I have used sample code provided at this url:

http://drupal.org/node/365334

but the page is giving implode warning on this line:

print "<b>".$amazon['title']."</b> de ".implode(',',$amazon['author'])."<br>";

Is it some beta version problem? On Amazon module test page (admin/settings/amazon/test) the same ISBN (286325507X) is providing correct results, which means API and keys are fine.

Looking forward for your support!

Comments

rfay’s picture

Status: Active » Fixed

The key item is that the ASIN you provided (286325507X) is not valid on Amazon.com, so nothing is going to work with it. (If you search for this ASIN on amazon.com you get nothing)

Are you working with some other locale than US?

So the item is not valid, and the code seems to try to process the result anyway.

Please demonstrate the problem with a valid ASIN.

ehtisham’s picture

Status: Fixed » Active

Hello,

Sorry I forgot to mention. I am working in french language. The sample ASIN provided (i.e. 286325507X) is giving results on amazon.fr website.

Is there some special function to be used or some extra perimeter to pass to make the code work? The same ASIN is giving correct results for the Amazon test interface available at: admin/settings/amazon/test.

Thanks,

rfay’s picture

Status: Active » Postponed (maintainer needs more info)

You'll have to debug this yourself in order to get enough information that we can help you.

Direct use of the function calls is not really supported here in the issue queue, but I'll help you *if* you debug it and get more explicit information.

You'll need to use something like print_r() or var_dump() to figure out where in your code you're having the problem. Once you're there, you should be able to say something like:

amazon_item_lookup("286325507X") does not return a correct data structure...

-Randy

ehtisham’s picture

Status: Postponed (maintainer needs more info) » Active

Hello Randy,

Thanks for your guidance. The following codes produces no result at all for the ISBN 286325507X

 print_r($amazon); 

Result: Nothing is displayed.

However for another another ISBN array is displayed just fine for the same debug code:

Array
(
[asin] => 2744063150
[title] => La semaine de 4 heures
[detailpageurl] => http://www.amazon.fr/semaine-4-heures-Timothy-Ferriss/dp/2744063150%3FSu...
[salesrank] => 935
[brand] =>
[publisher] => Pearson Education
[manufacturer] => Pearson Education
[mpn] =>
[studio] => Pearson Education
[label] => Pearson Education
[binding] => Broché
[releasedate] =>
[listpriceamount] => 2000
[listpricecurrencycode] => EUR
[listpriceformattedprice] => EUR 20,00
[productgroup] => Book
[producttypename] => ABIS_BOOK
[timestamp] => 1255519573
[author] => Array
(
[0] => Timothy Ferriss
)

[participants] => Array
(
[0] => Timothy Ferriss
)

[imagesets] => Array
(
[largeimage] => Array
(
[size] => largeimage
[url] => http://ecx.images-amazon.com/images/I/51SW0vyrMwL.jpg
[height] => 500
[width] => 407
)

[mediumimage] => Array
(
[size] => mediumimage
[url] => http://ecx.images-amazon.com/images/I/51SW0vyrMwL._SL160_.jpg
[height] => 160
[width] => 130
)

[smallimage] => Array
(
[size] => smallimage
[url] => http://ecx.images-amazon.com/images/I/51SW0vyrMwL._SL75_.jpg
[height] => 75
[width] => 61
)

)

[deweydecimalnumber] =>
[edition] =>
[numberofpages] => 301
[publicationdate] => 2008-01-12
)

When I use var_dump

var_dump($amazon); 

It prints NULL in content, for ISBN: 286325507X while it displays data for other ISBNs e.g. 2744063150

Ehtisham

rfay’s picture

I should have asked you to do this earlier:

1. Look in the log (admin/reports/dblog) to see if there's anything there that gives light.
2. The logging is much improved in the current dev version, so please try that and look at what you get for logs.
3. Look in your amazon_item db table and see what's there. You may have a bad record for this item. You can truncate that table (go ahead and make a backup first). When it gets truncated, it gets rebuilt as item pages are revisited.

Now for additional next steps in your debugging career:

I'm assuming, of course, that you're working on a local dev copy of the site.

1. Start placing print_r or var_dumps within Amazon module at the key places. Is amazon_item_lookup_from_db() the issue? amazon_item_lookup_from_web()?

My bet is that it's going to be a database issue, since the test lookup works.

When you figure out the issue, try to figure out how to solve it. It has to be something pretty simple, as the test works. Patches are accepted: http://drupal.org/patch.

Good luck,
-Randy

rfay’s picture

Status: Active » Fixed

I just tested this using the France locale and a simple snippet of PHP using the PHP block provided by the Devel module.

$item = amazon_item_lookup('286325507X');
print_r($item);

It worked perfectly, returning a full Amazon data structure.

I recommend you remove the offending item from your database; I'm assuming that's what's going on.

ehtisham’s picture

Hi Randy,

Thank you for your help, after clearing amazon_item database results are being fetched. :-)

Cheers,
Ehtisham

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.