Amazon Affiliate Link checker – tool 2.0

I’ve been wrestling with the Amazon API and found this great php snippet written by the people over at patchesoft.

Basically they have written a complete class I can call in my scripts to handle all of the communication with the Amazon API for me.

Now I am a complete newbie when it comes to PHP programming, let alone communication with an API.

So I am pretty chuffed to have come up with what I have done so far. Right now the checker tool scans a webpage for any tags with “href” in it, then it assumes those are websites.

That is a pretty safe bet.

Then it checks whether or not “shortened” url’s have been used, as is the case in a lot of affiliate links. It then unwraps the url and digs the associate tag and the product’s ASIN code from the URL.

Afterwards it uses the AmazonAPI-class to make a call to the API with the ASIN in question. It then checks what response it gets for availability when making a call with the ASIN of the product.

If it is an empty response then we just assume that the product is either unavailable, or “available from these sellers”. Both cases will result in my checker showing a “Unavailable” status however..

Things learnt:

-In the Amazon API class there is a field way up reserved for the different types of response groups. These response groups are important to list and details can be found here on what belongs where. At first I didn’t list the response groups that have the availability parameter in it and I was scratching my eyes out why my code wouldn’t work. The path etc was correct. But as I wasn’t including any of the necessary response groups in MY response XML there was no such field as <Availability>.

-PHP security. I have to use my own accessID and scecret key to make calls to Amazon’s Product Advertising API. So a challenge was to think of how to store that data in a safe way. Utilizing varous tricks to limit access to the private side of my website was a new experience!

-In general PHP coding. It seems a lot online is handled through PHP so it’ll be interesting to delve deeper into what kind of information can be passed back and forwards through pages, inputfields and tables.
Especially as I’ll be building another tool I dicussed earlier. For that project I’ll be needing a lot more php to access and store database information!


Things to do:

Right now the crawler just browses the given page and only returns the amazon links.

It would make sense that if you give the main domain of your website, the crawler would start crawling also a few levels deeper so you won’t have to.

So if you for example give your site “” and on your homepage you have a menu, then the crawler would crawl through those menu-links, and return any amazon links that may be there.

This has been suggested by already a few people I have spoken too.

A few issues though is that my script isn’t the fastest around. In fact it’s dead-slow.

So 2 things need to be done:

  1. Speed up the PHP-script so that it cycles through the found links faster
  2. Go as deep as possible when crawling a website and return the URL for the page the crawler is on, to the main table we have all come to know and love <3.

Leave a Reply

Your email address will not be published. Required fields are marked *