« blib/lib/Keystone/Resolver/plugins/Citation/author.pm
↑ Summary
blib/lib/Keystone/Resolver/plugins/ID/urn/isbn.pm »
| 1 | # $Id: doi.pm,v 1.2 2007-01-26 13:53:48 mike Exp $ | ||
| 2 | |||
| 3 | package Keystone::Resolver::plugins::ID::info::doi; | ||
| 4 | |||
| 5 | use strict; | ||
| 6 | use warnings; | ||
| 7 | |||
| 8 | |||
| 9 | sub data { | ||
| 10 | my $class = shift(); | ||
| 11 | my($openurl, $doi) = @_; | ||
| 12 | |||
| 13 | # The obvious DOI resolver to use is the one at | ||
| 14 | # http://dx.doi.org/ | ||
| 15 | # which can be invoked using a simple GET, like this: | ||
| 16 | # http://dx.doi.org/10.1126/science.275.5304.1320 | ||
| 17 | # The problem is that this doesn't resolve to a metadata set, but | ||
| 18 | # directly to a URL for the full text ... which may or may not be | ||
| 19 | # what we want. | ||
| 20 | |||
| 21 | my $req = "http://dx.doi.org/$doi"; | ||
| 22 | my ($uri, $errmsg) = $openurl->co()->fetch($req, "DOI", 1); | ||
| 23 | if (!defined $uri && $errmsg =~ /200 OK$/) { | ||
| 24 | # This is ugly, but that's how it goes when you screen-scrape. | ||
| 25 | # The only reason the DOI resolver would give us a page of | ||
| 26 | # HTML would be to report an error, so we know there's | ||
| 27 | # something wrong with the DOI. | ||
| 28 | $errmsg = "invalid DOI ($doi)"; | ||
| 29 | } | ||
| 30 | |||
| 31 | return ($uri, "info:doi", undef, $errmsg, 1); | ||
| 32 | } | ||
| 33 | |||
| 34 | |||
| 35 | 1; |