Hello
r> Do I need to send an FOXML file to accomplish an injest?
It can be METS or Atom I think. I use METS 1.1.
Here is some PHP that works for me. I found that the CURLOPT_HTTPHEADERs
needed to be set, otherwise Fedora would not recognise the content of the
POST as being the XML it was looking for.
Authentication is done with CURLOPT_HTTPAUTH => CURLAUTH_BASIC and
CURLOPT_USERPWD => $fedoraUserPwd, where $fedoraUserPwd is
"userName:passWord".
If you use a self signed certificate, then you need to set
CURLOPT_SSL_VERIFYPEER to false.
Hope this helps.
Swithun.
<?php
$protocol = "https";
$host = "my.fedora.host";
$port = 443;
$context = "fedora";
$fedoraUserPwd = "fedoraAdmin:topsecret"; // username:password
$fedoraVerifyPeer = false; // false for ignoring self signed certificates
$pid = "my_prefix:my_pid";
$fileName = "test.xml";
$xml = file_get_contents($fileName);
// probably don't need most of these
$queryArgs = array("label" => "A committee appointed for controverted
elections",
"format" => "info:fedora/fedora-system:METSFedoraExt-1.1",
"encoding" => "UTF-8",
"namespace" => "my_prfefix",
"ownerID" => "fedoraAdmin",
"logMessage" => "test ingest");
// generate URL, encoding query string
$url = sprintf("%s://%s:%d/%s/objects/%s?%s",
$protocol,
$host,
$port,
$context,
$pid,
http_build_query($queryArgs));
// this seems to be vital for getting Fedora to recognise the POST content
$headers = array("Accept: text/xml", "Content-Type: text/xml");
$curl_opts = array(CURLOPT_RETURNTRANSFER => true,
CURLOPT_URL => $url,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_USERPWD => $fedoraUserPwd,
CURLOPT_HTTPAUTH => CURLAUTH_BASIC,
CURLOPT_SSL_VERIFYPEER => $fedoraVerifyPeer,
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $xml);
$ch = curl_init();
curl_setopt_array($ch, $curl_opts);
$pid = curl_exec($ch); // get new PID returned
print $pid . "\n";
?>
--
The University of St Andrews is a charity registered in Scotland: SC013532
------------------------------------------------------------------------------
10 Tips for Better Server Consolidation
Server virtualization is being driven by many needs.
But none more important than the need to reduce IT complexity
while improving strategic productivity. Learn More!
http://www.accelacomm.com/jaw/sdnl/114/51507609/
_______________________________________________
Fedora-commons-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/fedora-commons-users