SWORD PHP library

As part of the JISC funded SWORD2 project, I have now written a PHP library for SWORD which is now available for download from:

http://php.swordapp.org/

There are many web applications that could deposit into repositories using SWORD, and many of these are written in PHP. Examples might include open source Content Management Systems, Blogs or Wikis. By using this library you can easily retrieve service documents and make deposits by using the API provided. There are two simple method calls (one to retrieve a service document and one to deposit a file). In addition there is a packager included that can package a file and metadata together into a package format supported by both DSpace and EPrints. This is the same code which is used to power the Facebook SWORD deposit tool (http://fb.swordapp.org/).

The code is currently an early release – version 0.4. It has now been tested again DSpace, EPrints, Fedora and Intralibrary. This means that the Facebook application will now successfully deposit to all four of these (previously there was an issue with EPrints as it returned its atom documents using the default atom namespace and the PHP library didn’t cope with default namespaces. The library has now been fixed to cope with that). However there are likely to be issues discovered as it is used more, so please feel free to try out the code and get in touch if you find any issues.

The code will shortly be upgraded to support the new SWORD version 1.3 specification.

The library requires PHP5, built with SimpleXML (to parse the XML responses from the repositories) and CURL (for the HTTP functions).

Bookmark and Share
Posted on November 30, 2008 at 8:11 am by Stuart · Permalink
In: Uncategorized · Tagged with: , ,

4 Responses

Subscribe to comments via RSS

  1. Written by Alexis Lorca
    on January 3, 2010 at 4:56 pm
    Permalink

    Hi,

    I have just tryed your software and it is really cool.

    I have a question for you. Is there a way to chech prior to posting? ie: If i run your upload-test twice, i got 2 articles on the site… xxx/8 and then xxx/9 and so on…

    I’ll really appresiate your time and help.

    Alexis

  2. Written by Stuart
    on January 5, 2010 at 2:48 pm
    Permalink

    Hi Alexis,

    Unfortunately there isn’t. SWORD does not contain a mechanism to stop duplicate deposits.

    You may wish to look at EasyDeposit (http://wiki.github.com/stuartlewis/EasyDeposit) which allows you to make SWORD user interfaces easily.

    Thanks,

    Stuart

  3. Written by O-Zone
    on August 5, 2010 at 1:20 am
    Permalink

    Hi Stuart,
    i got this error with EPrint SWORD gateway:

    ERROR

    2010-08-04T13:14:43Z

    OASI
    Institutional Repositor
    Failed to parse the HTTP headers.

    and this is the CURL verbose output:

    > > POST /sword-app/deposit/inbox HTTP/1.1

    Authorization: Basic xxxx
    Host: oasi.unisi.it

    Accept: */*

    User-Agent: SWORDAPP PHP library (version 0.9) http://php.swordapp.org/

    Content-MD5: 7fc400fec2546105a91e611ebabdc7bb

    X-On-Behalf-Of: docente

    X-Packaging: http://purl.org/net/sword-types/METSDSpaceSIP

    Content-Type: application/zip

    Content-Length: 1959

    Content-Disposition: filename=

    Transfer-Encoding: chunked

    < HTTP/1.1 400 Bad Request
    < Date: Wed, 04 Aug 2010 13:14:43 GMT
    < Server: Apache/2.2.9 (Debian) PHP/5.2.6-1+lenny8 with Suhosin-Patch
    mod_ssl/2.2.9 OpenSSL/0.9.8g mod_perl/2.0.4 Perl/v5.10.0
    < Content-Length: 461

    < Connection: close

    < Content-Type: application/atom+xml

    Can you help me ?

  4. Written by Stuart
    on August 7, 2010 at 3:41 pm
    Permalink

    Hi,

    I wonder if the file is failing to transmit properly for some reason? It thinks the size of the file you are sending is 1959kb, but the repository thinks it receives a file of size 461kb (see the content-length headers).

    Is there anything in the EPrints log files about what might have happened?

Subscribe to comments via RSS

Leave a Reply