I am just trying this module, but cannot get anything working.

- the test fails with the subject message
- The cck field returns the following:

warning: Invalid argument supplied for foreach() in /home/controlc/www/sites/all/modules/amazon/amazon.module on line 348.
Amazon item : No Amazon product with the ASIN "0979560810" could be located.
warning: Invalid argument supplied for foreach() in /home/.../amazon/amazon.module on line 348.

My settings (associate ID, AWS account ID and access keys) are OK

Any idea?

Thanks for help

Comments

rfay’s picture

What locale are you using? Does this ASIN show up on that locale?

I would not be surprised if your AWS access keys are the issue, so please check them again. Make sure no spaces have snuck in at the beginning and the end. Make sure that you used copy and paste from the AWS site, rather than typing them in.

I have no trouble with testing this... I'm sure interested in getting your problem solved.

I will evaluate a database dump if you want to provide one for me. Just put it somewhere and post a link, or attach it to the issue if it's relatively small, or email me with a link through the contact form.

rfay’s picture

Title: warning: Invalid argument supplied for foreach() in .../amazon.module on line 348 » Test should detect and report invalid credentials
Category: support » task

I did just run a test with invalid credentials, and got this message.

So I would say your problem is the credentials. Again, use copy and paste to put them in.

Changing the title to suggest improvement

redcap’s picture

Category: task » support

I have the same problem. I checked my credentials, created new and used copy and paste to put them in.
But nothing worked. I stell get the 348 message.
Is there maybe another reason why the message appears?
Thanks

rfay’s picture

@redcap, I certainly want to get this solved for you. If you can dump your database and make it available to me, I'll load it up and debug it. You can email it to me at randy at randyfay.com if it's small, or email me a link to it.

redcap’s picture

Thank you so much randy!
i just send it to you.

rfay’s picture

Category: support » task

@redcap, doing *nothing* but pasting in my AWS credentials made this work. I used ASIN 0596515804 and your admin account.

I should note that it looked like update.php had not been run on this database, and I did run it, so there are a number of errors that would result from that, assuming you're using 6.x-1.0-beta10. But even then it looked up everything just fine.

To anybody that is having this trouble:

Please, please copy and paste the credentials from the AWS website. Make sure you get the whole thing. Look at it twice. Consider generating a new set of keys if you're having this error.

To everybody: Whenever you update a module, please remember to run update.php.

redcap’s picture

Status: Active » Fixed

Randy helped me and togehter we fixed the problem.

My hosting Provider has an Outgoing Connection Manager and blocked all Connections to "ecs.amazon.com". I don´t know why he is doing that, but when you allow the access to "ecs.amazon.com" everthing works fine.

Thank you very much Randy for you help!
Tom

ramper’s picture

I have been getting the same message on my local machine:
warning: Invalid argument supplied for foreach() in ..../sites/all/modules/amazon/amazon.module on line 348.
However, on my remote server (VPS), where I have the exact same file structure and everything the same as my local machine (except the OS: Fedora 11 on my local machine and Centos 5 on the remote server), everything seems to work fine with the same credentials. While that's a relief, I would really like to have it working on my local machine too - so I can do the site development locally before uploading. Since it's working on my remote server using the same credentials, I guess the problem may have something to do with my local settings? I have no problem with Google Adsense, though - the ad blocks display fine on my local machine. Has anyone faced a similar situation - where it works on the remote server, but not on the local machine? Any help would be appreciated.

rfay’s picture

Assigned: rfay » Unassigned
Issue tags: -6.x-1.0 blocker

I don't believe it has anything to do with remote vs local. In the case of @redcap (#7), the issue was that his provider was blocking access to ecs.amazonaws.com. Without access to that host nothing can happen.

Many local service providers block miscellaneous hosts, so that may be your issue.

Please do report back when you get this solved.

I'm reopening this one, as the issue of reporting credential failure still needs to be looked at, and maybe we can give a better error message in the case of a blocked host.

rfay’s picture

Assigned: Unassigned » rfay
Status: Fixed » Active
Issue tags: +6.x-1.0 blocker
jerome72’s picture

I still have this problem as well. I put my database on local, and the module works. I think that there are some blocked ports that prevent this module to work normally on my server.

Please can anyone tell me which ports I should open to make this great module work ?

Regards

rfay’s picture

Assigned: Unassigned » rfay
Issue tags: +6.x-1.0 blocker

@jerome72, you need to have access to the host ecs.amazonaws.com (72.21.211.34). Otherwise you can't do the Amazon API.

rfay’s picture

Status: Active » Fixed
StatusFileSize
new2.12 KB

Fixed this to allow error reporting in the dblog when a problem occurs.

1. The test doesn't try to deal with a no-data response (which is were the ugly errors were coming from).
2. The error message in the watchdog explains timeout (where your host is blocking ecs.amazonaws.com) and credentials errors (where you don't have the proper private key and such configured)

Committed to 6.x-1.x: http://drupal.org/cvs?commit=301944

jerome72’s picture

Dear rfay,

Thank you so much for posting that patch. I could get the error on my server which was :

Error accessing Amazon AWS web service. result code=400, error=Bad Request

Then I googled for that error code, and in my case I found that the time on my server was different from one hour with real time, and when I changed the time, it worked! Nothing to do with site blocking.

Thank you again for your help!
Regards
Jerome

rfay’s picture

@jerome72, thanks for your feedback. based on that I made it give still more information for a 400 error. Maybe that will help people in the future with this sort of problem. We've seen the time problem before.

Status: Fixed » Closed (fixed)

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

Seneschall’s picture

Sorry to re-open, but I just want to get clarification. I'm also getting

"HTTP code 400 accessing Amazon's AWS service: RequestExpired, Request has expired."

So this means that the time set on the physical server is different? Or is it my laptop. I'm using United States for the amazon API but my server is located in Hong Kong.

Cheers!

rfay’s picture

There have been two problems I've seen in relation to this:

1. The server is running on the wrong machine timezone. All servers should run with their machine time set to UTC/GMT, and then the timezone data should adjust to wherever the user is (and it doesn't matter where in the world you are). So if you log in to the server, and set your timezone to the correct timezone, you should see the right time. Logging into the server, the "date" command should give you something like Fri Mar 12 22:40:06 MST 2010, and it should show the correct time now and your timezone. If it doesn't, you should be able to set your timezone with something like "export TZ=EST" (for Eastern time) and it should then show the correct time when you use the date command. If you can't get this combination to work, the machine time is wrong.

2. The server just has the wrong time set. You can tell this by just using the date command.

Seneschall’s picture

Thanks! I'll talk to my HK people about it. Cheers!

Eric