Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
test datacite metadata and coin
#! /usr/bin/perl
use LWP;
use Crypt::SSLeay;
use utf8;
$xml= <<EOXML;
<resource xmlns="" xmlns:xsi="" xsi:schemaLocation="">
<identifier identifierType="DOI">$doi</identifier>
<creatorName>test, test</creatorName>
my test title
<publisher>Publ test</publisher>
<resourceType resourceTypeGeneral="Text">BookSection</resourceType>
<alternateIdentifier alternateIdentifierType="URL"></alternateIdentifier>
$res=datacite_request("POST", $url."metadata", $user_name, $user_pw, $xml, "application/xml;charset=UTF-8");
print $res->as_string;
my $doi_reg = "doi=$doi\nurl=".$doiurl;
$res=datacite_request("POST", $url."doi", $user_name, $user_pw, $doi_reg, "text/plain;charset=UTF-8");
print $res->as_string;
sub datacite_request {
my ($method, $url, $user_name, $user_pw, $content, $content_type) = @_;
my $headers = HTTP::Headers->new(
'Accept' => 'application/xml',
'Content-Type' => $content_type
my $req = HTTP::Request->new(
$method => $url,
$headers, $content
$req->authorization_basic($user_name, $user_pw);
my $ua = LWP::UserAgent->new;
my $res = $ua->request($req);
return $res;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment