This post is obsolete. See the updated post.
Since AVH Amazon plugin no longer works, as Amazon in its infinite wisdom removed the ListLookup API call, I had to create my own. Without an API, I resorted to a hacker's best friend: screen scraping. The wishlist page has a simple structure, and all links to Amazon products have as part of the URL "dp/{ASIN}
", where {ASIN}
is the Amazon ID number. If you view a wishlist in compact form, then the only links are to wishlist items and all the items (as far as I can tell) will be on a single page. Other advertisements for Amazon products that you see on the page are added with Javascript, so they won't show up when we grab the page with PHP.
So it's easy to get a list of ASIN's of the products on my wishlist:
function wishlist($listname){
$url = "http://www.amazon.com/registry/wishlist/$listname?layout=compact";
$contents = file_get_contents($url);
preg_match_all ('|/dp/(\w+)/|', $contents, $ASINs, PREG_PATTERN_ORDER);
return $ASINs[1]; // just get the numbers
}
This returns an array of ASIN's, that you can now pass the the Amazon ItemLookup API, which still works fine (Ulrich Mierendorff's AWS Signed Query makes that easy).
If your web hosting service disables file_get_contents, as mine does, you can use cURL instead.
As you can see from my sidebar, it seems to work well. Obviously, Amazon can change the layout and content of their pages without notice, but as we have seen, they can change the API as well.