Archive for October, 2010

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.

The Centers for Disease Control and the American Academy of Pediatrics just recommended that pediatricians stop using the old growth charts, based on 40 years of NHANES data, and switch to new charts from the World Health Organization, for children less than 2. The NHANES study is a survey of child health from the United States, and the original charts based on that data was descriptive: the charts showed what the distribution of heights and weights was for American children. That was used by pediatricians to define "normal," to say whether you were overweight or underweight. With the 2000 charts, they decided that kids were too heavy and that we couldn't call that "normal" anymore. So they effectively threw out all the recent weight data, and made the charts based on the 1970 distribution of weight (see page 16 of the original paper) and made the charts partly prescriptive (telling us what they thought the distribution of weight should be) and partly descriptive.

Now they've gone all the way: the WHO explicitly followed an international group of babies who were "were raised in environments that promote healthy growth", including exclusively breastfeeding to 4 months and continuing breastfeeding to 12 months, no smoking, and rich enough to be able to eat well.

I updated the bililite webservices charts to reflect the new charts, but I'm of two minds about the change. As a pediatrician following a kid's weight, I really do want to compare it to "healthy" rather than "common," so the change is for the better. On the other hand, it enshrines assumptions about what "healthy" means without good evidence that children who fall in the prescribed ranges actually live longer, healthier lives. We will get more recommendations for further restricting our children's lives in order to force them onto these graphs.

As these charts get more use, look for more press about increasing obesity, as we redefine the percentile lines downward, pushing more kids over the "overweight" 85th percentile. It's like the AMT of biostatistics!

I've been using Peter van der Does's AVH Amazon plugin to display my Amazon wish list (more as an "about my interests" than a "buy things and make me money") and it's worked well, allowing a random selection of books I would like to be shown in the sidebar. Now it's dead, killed by Amazon's deprecating the API to get the wish list items. It seems short sighted, especially since Amazon's wish list widget is so limited and poorly formatted (it's on the sidebar now). I may look into creating my own, if I ever have free time again.