• Like
  • Save
Introduktion till API:er, webbtjänster & att integrera LIBRIS tjänster i OPAC
Upcoming SlideShare
Loading in...5
×
 

Introduktion till API:er, webbtjänster & att integrera LIBRIS tjänster i OPAC

on

  • 3,362 views

Del av workshopen i projektet Att använda LIBRIS öppna infrastruktur

Del av workshopen i projektet Att använda LIBRIS öppna infrastruktur

Statistics

Views

Total Views
3,362
Views on SlideShare
3,240
Embed Views
122

Actions

Likes
1
Downloads
18
Comments
0

5 Embeds 122

http://www.betabib.org 87
http://www.slideshare.net 30
http://hdabibit.blogspot.com 3
http://static.slidesharecdn.com 1
http://feeds.feedburner.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Introduktion till API:er, webbtjänster & att integrera LIBRIS tjänster i OPAC Introduktion till API:er, webbtjänster & att integrera LIBRIS tjänster i OPAC Presentation Transcript

    • Att använda LIBRIS öppna infrastruktur
      Högskolan i Jönköping
      20-21 maj 2010
    • #librisAPIws
    • 20 maj
      12.00 – 12.10 Inledning
      12.10 – 13.00 Tankarna bakom LIBRIS öppna infrastruktur
      13.00 – 13.30 Introduktion till API:er, webbtjänster och LIBRIS system
      13.30 – 14.30 Integrera LIBRIS tjänster i din OPAC
      14.30 – 15.00 Paus
      15.00 – 16.00 Integrera LIBRIS tjänster i din webbplats
      16.00 – 17.00 Att skapa en söktjänst med LIBRIS som komponent
      17.00 – Gruppdiskussioner på temat Vad skulle du vilja göra med LIBRIS API:er och tjänster?
      21 maj
      09.00 – 09.30 Återkoppling till gårdagens diskussion
      09.30 – 10.00 SUB:s arbete med LIBRIS API:er
      10.00 – 10.20 Paus
      10.20 – 11.20 Hur kommer LIBRIS öppna infrastruktur att utvecklas, vad kan vi förvänta oss i framtiden?
      11.20 – 12.00 Öppna frågor till en panel med de som presenterat under dagarna
      12.00 – 12.30 Hur går vi vidare, uppföljning, avrundning och avslutning
    • Introduktion till API:er, webbtjänster &
      att integrera LIBRIS tjänster i OPAC
      Daniel Forsman
      Chalmers bibliotek
      Att använda LIBRIS öppna infrastruktur
      20 maj 2010
    • ”Basic scholarly information usepracticeshaveshiftedrapidlyin recent years,
      and as a result the academiclibrary is increasinglybeingdisintermediated from the
      discoveryprocess, riskingirrelevancein one of itscorefunctionalareas”
      Ithaka S+R 2009 FacultySurvey Report
      The future of libraries? Technology has created a verydifferent contextfor the
      missions of academic and research libraries
      No Brief Candle, DaphneeRentfrow
    • LIBRIS
      ILS
      OPAC
      CAT
      ACQ
      ILL
      CAT
      OPAC
      Patron
      CIRC
    • OA
      Arkiv
      Linked data
      Fed. search
      Link
      Resolv.
      ERM
      LIBRIS
      ILS
      Aggr.
      Rekommendation
      Proxy & SSO
      OPAC
      CAT
      ACQ
      ILL
      CAT
      RDF
      ILL
      OPAC
      Patron
      Aggr. DB
      Discovery
      CIRC
      Integratedsearch
      Amazon
      Google
      Enskild DB
      OER
      Digitalisering
    • Lokalt
      Globalt
      Kontext
      SaaS
      Nationellt
      Individ
      Konvergens
      Paradigm
      skifte
      Institution
      System
      Bransch
      glidning
      OS
      Sam
      arbete
      Digitalisering
      Institutionella arkiv
      Linked data
      API
      Mobil
      Data
      OA
      Open
      Data
      Kanaler
      Webb
      Licens
      Bib. service
      Lokaler
      DaaS
      VLE
    • Öppenhet i en tjänstebaserad värld
      Open standards
      Open Access
      Open educationalresources
      Open source
      Open platform
      Open data
      Garanti för teoretisk valfrihet
    • Webben har blivit en plattform där gränssnitten frikopplas från systemen och de underliggande tjänsterna
      Decoupling of frontend from backend
      WorldcatAPI, XISBN, LibraryThing for Libraries , LIBRIS Xsearch, MetaLib | Aleph X-server, SFX API, EbscoHost Integration Toolkit,
      ISI Web Services, Amazon, SRU/W, RDF | Linked Data, Google Code, Flickr API, Yahoo! Developer Network, Yahoo! Pipes … … …
    • API?
      ”An ApplicationProgramming Interface (API) is an interface implemented by a software program whichenables it to interact with other software. It is similar to the way the user interface facilitates interaction between humans and computers. An API is implemented by applications, libraries, and operating systems to determinetheirvocabularies and calling conventions, and is used to access their services. It mayincludespecifications for routines, data structures, object classes, and protocols used to communicatebetween the consumer and the implementer of the API”
      // Wikipedia – ApplicationProgramming Interface
    • Webbtjänst?
      “A Web service is a software system designed to support interoperable  machine­to-machine interaction over a network. It has an interface described in a machineprocessable format (specifically WSDL). Other systems interact with the Web service in a mannerprescribed by itsdescriptionusing SOAP messages, typicallyconveyedusing HTTP with an XML serialization in conjunction with other Web related standards.“
      // W3C definition
      Web services are frequently just Internet Application Programming 
      Interfaces (API) that can be accessed over a network, such as the 
      Internet, and executed on a remote system hosting the requested 
      services.  // Wikipedia – Web service
    • SOAP & REST
      REST –Representational State Transfer - är en arkitektur för att tillhandahålla tjänster för maskin till maskin-kommunikation. Varje resurs är unikt adresserbar enligt en gemensam standard (URI). Grundläggande kommandon för att interagera med objekt baserade på de verb som är angivna i HTTP-standarden: POST, GET, PUT och DELETE.
      // http://sv.wikipedia.org/wiki/Representational_State_Transfer
      SOAP – Simple Object Access Protocol, men inte från och med 1.2, ett protokoll för utbyte av strukturerad information i form av XML
      SOAP provides a simple and lightweightmechanism for exchangingstructured and typed information betweenpeers in a decentralized, distributedenvironmentusing XML. SOAP does not itselfdefineanyapplicationsemanticssuch as a programmingmodel or implementationspecificsemantics; rather it defines a simple mechanism for expressingapplicationsemantics by providing a modularpackagingmodel and encodingmechanisms for encoding data withinmodules. This allows SOAP to be used in a largevariety of systems ranging from messaging systems to RPC
      // http://www.programmera.net/webservice/soap.php
    • AJAX är en akronym för Asynchronous JavaScript and XML (Asynkron JavaScript och XML) som är ett samlingsnamn för ett antal olika tekniker som kan användas för att bygga applikationer för World Wide Web med bättre interaktivitet än tidigare webbapplikationer. Kända tjänster som använder dessa lösningar är Gmail, Google Maps och Facebook.
      XMLHttpRequest-objektet, som tillåter JavaScript på en webbsida att göra anrop till webbservern utan att sidan laddas om.
      DOM (DocumentObjectModel) vilket tillåter JavaScript att skriva om innehåll på den aktuella sidan.
      //http://sv.wikipedia.org/wiki/AJAX
      DocumentObjectModel, förkortat DOM, är ett plattforms- och språkoberoende gränssnitt för åtkomst och dynamiskt uppdatering av ett dokuments innehåll, struktur och formatering.
      // http://sv.wikipedia.org/wiki/Document_Object_Model
    • Vad behöver man?
      För att fånga upp element på en webbsida manipulerar man DOM
      Med XMLhttpRequest kan man skicka och få tillbaka data till webbläsaren utan att ladda om den
      Javascript bibliotek som jQuery och Prototype gör detta enkelt
      JSON-formatet gör att man kan läsa in data direkt i klienten via javascript
      JSON (JavaScript Object Notation) is a lightweightdata-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate.
      // http://www.json.org/
      Om man inte kan få JSON utan ett XML format måste detta hanteras på servern där scriptet körs PERL, PHP, Python, Ruby osv.
      Säkerhetsinställningarna för XMLhttpRequest gör att man inte kan anropa ”externa” servrar,
      anrop måste ske lokalt eller via proxy
      Mina exempel bygger i huvudsak på PHP och Prototype
    • Varför integrera webbtjänster i OPAC?
      By exploringweb services and new technology wegain first hand experiencemakingusstrongercustomers and development partners
      Strategy is to present libraryresources in a singlethoughtthroughstructure and presentation BUT ALSO to identify key services and make themavailableoutside the librarywebsite. Webservicesallowsus to do this.
      By integrating services the localcollection is displayed in a broadercontext, part of a widenetwork of resources. The librarywebsite or OPAC turnsinto a small federatedsearch service, rich in functionality and content, seamlesslyintegrated.
      Att kunna visa lokala resurser i ett regionalt, nationellt och globalt sammanhang
    • OPAC:en är inte decoupled …
      Men de flesta tillåter att man stoppar in javascript
      Javascript tillsammans med en ”hook” kan agera med ett serverside script
      XML format spelar ingen roll för mig … metoden går att återanvända genom att använda PHP:s
      färdiga funktioner för att göra anrop och bearbeta XML
    • Hooki full-999-body
      <!-- filename: full-999-body -->
      <span id="$0100”>$0200
      <span>
      <br />
    • CSS selectors
      Javascript
      document.getElementById()
      jQuery : jQuery('#id')
      <divid="myDiv">id="myDiv"</div> <script>$("#myDiv").css("border","3px solid red");</script>
      http://api.jquery.com/category/selectors/
      Prototype : $$('#contents');
      getElementsbyTagName
      getElementsbyClassName
      http://api.prototypejs.org/language/dollardollar/
    • //putissn in xissn variable
      var xissn=document.getElementById("ISSN");
      //pass issn to backend script, echoresult in diveJULIA
      new Ajax.Updater('eJULIA', ’sfx.php', { method: 'get', success: 'eJULIA', failure: 'errors', parameters: {issn: xissn.innerHTML}
    • OPAC -> DOM manipulation -> AJAX -> PHP -> Webbtjänst -> OPAC
    • http://libris.kb.se/xsearch?query=word+of+mouth+marketing&format=mods
    • Att fånga söktermer
      <script type="text/javascript">
      //Retreive and store webpage URL
      var TITLE = document.URL;
      if(TITLE.search("request") > -1) {
      //Find position of request in URL
      var where_is_start1=TITLE.indexOf('request');
      //Find the position of &find_code
      if(TITLE.search("&x=") > -1) {
      var where_is_end1=TITLE.indexOf('&x=');
      }else{
      var where_is_end1=TITLE.indexOf('&find_code=');
      }
      //Define a the position wheresearchwords start - at the end of request
      var new_start=where_is_start+8;
      //Put the searchwords in a string, defined by start and end position
      searchword = TITLE.slice(new_start, where_is_end);
      }
      </script>
    • new Ajax.Updater(’libris', ’libris.php', {method: 'get', success: ’libris',
      failure: 'errors', parameters: {libristerm: searchword} });
    • <?php
      echo ’<STYLE TYPE="text/css">
      a {text-decoration:none;}
      font-family:verdana,arial,helvetica,sans-serif;
      </style>';
      error_reporting(0);
      $word=$_GET["libristerm"];
      $request = 'http://libris.kb.se/xsearch?query='.$word.'&format=mods';
      $xml = simplexml_load_file($request);
      $Base = $xml->modsCollection;
    • if (empty($Base->mods)){
      //do nada
      }else{
      echo "<h2>LIBRIS Results<br><i>National union catalog</i></h2><ol>";
      $x = "1";
      foreach ($Base->mods as $item) {
      echo "<li><ahref=http://libris.kb.se/hitlist?d=libris&q=";
      echo $word;
      echo "&f=simp&spell=true&hist=true&p=1 STYLE='text-decoration: none;'>";
      echo $item->titleInfo->title;
      echo "</a> ";
      echo $item->name->namePart;
      echo "</li>";
      $x++;
      }
      echo "</ol><divalign=right><br /><a href=http://libris.kb.se/hitlist?d=libris&q
      =$word&f=simp&spell=true&hist=true&p=1>View results in LIBRIS</a></div>";
      }
      ?>
    • http://libris.kb.se/xsearch?database=swepub&query=agriculture+economy&format=mods
    • //Start Swepub
      $SWErequest = 'http://libris.kb.se/xsearch?database=swepub&query='.$word.'&format=mods';
      $SWExml = simplexml_load_file($SWErequest);
      $SWEBase = $SWExml->modsCollection;
      if (empty($SWEBase->mods)){
      //do nada
      }else{
      echo "<h2>SwePub - Tr&auml;fflista</h2><ol>";
      $SWEx = "1";
      foreach ($SWEBase->mods as $SWEitem) {
      echo "<li><ahref=";
      echo $SWEitem->identifier;
      echo " STYLE='text-decoration: none;'>";
      echo $SWEitem->titleInfo->title;
      echo "</a> ";
    • $author_array = array();
      foreach ($SWEitem->name as $SWEau){
      array_push($author_array, $SWEau->namePart);
      }
      $au_count = count($author_array);
      if ($au_count >= 2){
      echo "$author_array[0] et al";
      }else{
      echo "$author_array[0]";
      }
      echo "</li>";
      $SWEx++;
      }
      echo "</ol><divalign=right><br /><a href=http://swepub.kb.se/hitlist?d=swepub&q=$word&f=simp&spell=true&hist=
      true&p=1>Till tr&auml;fflista i SwePub</a></div>";
      }
      ?>
    • http://uppsok.libris.kb.se/sru/uppsok?&operation=searchRetrieve&query=%22information+retrieval%22&maximumRecords=10&recordSchema=dc&x-render-output=xml
    • <?php
      error_reporting(0);
      $word=$_GET["uppsokterm"];
      $request = "http://uppsok.libris.kb.se/sru/uppsok?&operation=searchRetrieve&query=%22$word%22&maximumRecords=10&recordSchema=dc&x-render-output=xml";
      $xml = simplexml_load_file($request);
      $Base = $xml->records;
      if (empty($Base->record)){
      //Wecouldsaysomething … men nej
      }else{
      echo "<h2>Upps&ouml;k <br><i>Uppsatser & Examensarbeten</i></h2><ol>";
    • $x = "1";
      foreach ($Base->record as $item) {
      echo "<li><ahref=";
      echo $item->recordData->dc->identifier;
      echo " STYLE='text-decoration: none;'>";
      echo $item->recordData->dc->title;
      echo "</a> ";
      echo $item->recordData->dc->creator;
      echo "</li>";
      $x++;
      }
      echo "</ol><divalign=right><br /><a href=http://uppsok.libris.kb.se/sru/uppsok?query=anywhere+all+%22$word%22&maximumRecords=25&stylesheet=arkivx-hitlist.xsl&operation=searchRetrieve&recordSchema=dc&startRecord=1>Till
      tr&auml;fflista i Upps&ouml;k</a></div>";
      }
      ?>
    • http://samsok.libris.kb.se/X?op=login_request&user_name=UID&user_password=PW
    • http://samsok.libris.kb.se/X?op=find_request&wait_flag=Y&find_request_command=WRD=%28america%29&find_base_001=LIB32223&session_id=GK9TA5RGP39F2THRDJI6X1VH2G4BBP6QEXNEMT47FLJIFRLCDQ
    • new Ajax.Updater(’metalib', '/php/metalib_e.php', { method: 'get', success: ’metalib',
      failure: 'errors', parameters: {name: searchword} });
    • <?php
      //Turnofferrorreporting
      error_reporting(0);
      include ’/file_outside_webroot/with/user/credentials.php';
      $wrd = $_GET['name'];
      $newrd = str_replace('?undefined', '', $wrd);
      $query_string = 'SEARCH_ANY=' . urlencode($newrd) . '';
      $dom = new DomDocument();
      $dom->load("http://samsok.libris.kb.se/X?op=login_request&user_name=$mluid&user_
      password=$mlpw");
      $sessions = $dom->getElementsByTagName("session_id");
      foreach($sessions as $session) {
      $session_id = $session->textContent;
    • $xmlDoc = new DOMDocument();
      $xmlDoc->load("http://samsok.libris.kb.se/X?op=find_request&wait_flag=Y&find_req
      uest_command=WRD=($newrd)&find_base_001=LIB40723&find_base_001=LIB39584&
      session_id=$session_id");
      $searchNode = $xmlDoc->getElementsByTagName( "base_info" );
      echo"<h2>Metasearch</h2><br />&nbsp;&nbsp;&nbsp;Results from metasearch via Sam
      s&ouml;k</i><ul>";
      foreach( $searchNode as $searchNode )
      {
      $xmlDate = $searchNode->getElementsByTagName( "no_of_documents" );
      $count = ltrim($valueDate = $xmlDate->item(0)->nodeValue, "0");
      if($count == ''){$count = "0";}
      $xmlAuthorID = $searchNode->getElementsByTagName( "full_name" );
      $valueAuthorID = $xmlAuthorID->item(0)->nodeValue;
      $xmlSet_number = $searchNode->getElementsByTagName( "set_number" );
      $valueSet_number = $xmlSet_number->item(0)->nodeValue;
    • echo "<li><a href=http://www.bibl.hj.se/databas/proxy.php?url=http://samsok.
      libris.kb.se/V/$session_id?func=meta-3&set_number=$valueSet_number STYLE='text-d
      ecoration: none;'>$valueAuthorID : $count</a></li>";
      }
      echo "</ul><br />";
      }
      ?>
    • http://link.libris.kb.se/sfxjon?sid=ALEPH:JUL01&issn=1501-7419&sfx.response_type=simplexml
    • <script type="text/javascript">
      var elem = document.getElementById("ISBN");
      elem.innerHTML = elem.innerHTML.replace(/[().-s,]/g, "");
      elem.innerHTML = elem.innerHTML.replace(/[^d]/g, "");
      if(elem){
      new Ajax.Updater('eJULIA', '/php/sfx_sv.php', { method: 'get', success: 'eJULIA', failure: 'errors', parameters: {isbn: elem.innerHTML}});
      }
      </script>
    • try{ var xissn=document.getElementById("ISSN");

      if(xissn){ var spinner = '<fieldset><legend>e-JULIAservices</legend><br /><center><img src="http://julia.hj.se/exlibris/aleph/u18_1/alephe/www_f_swe/icon/ajax-loader.gif"><h2>Fetching services</h2><br /></center></fieldset>';

      document.getElementById("eJULIA").innerHTML=spinner;
    • // removeallwhitespace
      xissn.innerHTML = xissn.innerHTML.replace(/s/g, "" );
      // remove /
      var IssnRegExp = new RegExp("/","g");
      xissn.innerHTML = xissn.innerHTML.replace(IssnRegExp, "");
      // remove <b>
      xissn.innerHTML = xissn.innerHTML.replace(/<b>/g, "" );
      new Ajax.Updater('eJULIA', ’sfx.php', { method: 'get', success: 'eJULIA', failure: 'errors', parameters: {issn: xissn.innerHTML}
    • SFX API
      <?php
      //Receive ISSN from ALEPH OPAC
      $issn=$_GET["issn"];
      $openurl = "http://link.libris.kb.se/sfxjon?sid=ALEPH:JUL01&issn=$issn&sfx.response_type=simplexml";
      //Make the call to SFX and loadresults
      $xml = simplexml_load_file($openurl);
      //Targets base
      $Base = $xml->targets;
      //HTML formating
      echo "<fieldset><legend>e-JULIAlinkservices</legend><ul>";
    • SFX API
      //Loop through results and present selected targets
      foreach ($Base->target as $target) {
      if($target->service_type == 'getHolding' ){
      echo "<li><a href=". $proxy.$target->target_url .">Search for title in ". $target->target_public_name . "</a></li> ";
      }
      if($target->service_type == 'getCitedJournal' ){
      echo "<li><a href=". $proxy.$target->target_url .">Search for ". $target->target_public_name . "</
      a></li> ";
      }
      if($target->service_type == 'getFullTxt'){
      echo "<li><a href=". $proxy.$target->target_url .">Fulltext available from ". $target->target_public_name . "</a></li> ";
      }
    • SFX API
      if($target->service_type == 'getAbstract'){
      echo "<li><a href=". $proxy.$target->target_url .">Abstract available from ". $target->target_pub
      lic_name . "</a></li> ";
      }
      if($target->service_type == 'getTOC'){
      echo "<li><a href=". $proxy.$target->target_url .">Table of content available from ". $target->ta
      rget_public_name . "</a></li> ";
      }
      }
      ?>
    • ticTOCs
      JULIA works with flat txtfile from JISC, converts it to XML and
      query it as a local service (butanyonecould …).
      journalTOCsnow offer a API that you canuseinstead of downloading
      a txtfile.
      http://www.journaltocs.hw.ac.uk/index.php?action=api
    • try{
      var xissn=document.getElementById("ISSN");
      var x2isbn=document.getElementById("ISBN");
      if(xissn){
      var spinner = '<fieldset><legend>e-JULIAtj&auml;nster</legend><br /><center><img src="http://julia.hj.se/exlibris/aleph/u18_1/alephe/www_f_swe/icon/ajax-loader.gif"><h2>H&auml;mtar tj&auml;nster</h2><br /></center></fieldset>';
      }else if(x2isbn){
      var spinner = '<fieldset><legend>e-JULIAtj&auml;nster</legend><br /><center><img src="http://julia.hj.se/exlibris/aleph/u18_1/alephe/www_f_swe/icon/ajax-loader.gif"><h2>H&auml;mtar tj&auml;nster</h2><br /></center></fieldset>';
      }else{
      var spinner = '';
      }
      document.getElementById("eJULIA").innerHTML=spinner;
    • if(x2isbn){
      new Ajax.Updater('eJULIA', ’sfx_sv.php', { method: 'get', success: 'eJULIA', failure: 'errors', parameters: {isbn: x2isbn.innerHTML}});
      }
      else{
      xissn.innerHTML = xissn.innerHTML.replace(/s/g, "" ); // remove all whitespace
      var IssnRegExp = new RegExp("/","g");
      xissn.innerHTML = xissn.innerHTML.replace(IssnRegExp, ""); // remove /
      xissn.innerHTML = xissn.innerHTML.replace(/<b>/g, "" ); // remove <b>
      new Ajax.Updater('eJULIA', ’sfx_dev.php', { method: 'get', success: 'eJULIA', failure: 'errors', parameters: {issn: xissn.innerHTML}
      });
      }
      }
      catch(err){
      }
    • //getSession, creates the session with the x-server, user/password
      functiongetSession($u,$p){
      //everything is returned in utf-8 make sure wehave a utf-8 encoding
      //header('Content-Type: text/html; charset=UTF-8');
      //Definecallerurl
      $get_session = "http://samsok.libris.kb.se/X?op=login_request&user_name=".$u."&user_password=".$p."
      ";
      //Make call
      $xml = simplexml_load_file($get_session);
      //XML base
      $Base = $xml->login_response;
      //Define the session variable
      $session = $Base->session_id;
      //functionreturns session id
      return $session;
      }
    • //Function to list all MetaLibcategories
      functiongetAllCategories($session){
      //Definecall URL
      $get_cats = "http://samsok.libris.kb.se/X?op=retrieve_categories_request&requester_ip=193.10.208.75
      &session_id=$session";
      //Make call
      $xml = simplexml_load_file($get_cats);
      //Define XML base
      $Base = $xml->retrieve_categories_response;
      //Loop througheverycategory, putcategoryname in variable.
      foreach ($Base->category_info as $cat){
      $category_name = $cat->category_name;
      echo "<fieldset><legend>".$category_name."</legend>";
      //Loop throughlooking for subcategories
      foreach($cat->subcategory_info as $sub){
      $subcategory_name = $sub->subcategory_name;
      $subcategory_count = $sub->no_bases;
      $subcategory_seq = $sub->sequence;
    • if($subcategory_name == 'ALL'){
      echo "<a href=getDBbyCat.php?sequence=".$subcategory_seq."&session=".$session."&nam
      e=".$subcategory_name.">ALLA ".$category_name." databaser</a> [".ltrim($subcategory_count,0)."]<br>
      ";
      }else{
      echo "<a href=getDBbyCat.php?sequence=".$subcategory_seq."&session=".$session."&nam
      e=".$subcategory_name.">".$subcategory_name."</a> [".ltrim($subcategory_count,0)."]<br> ";
      }
      }
      echo "</fieldset>";
      }
      // endfunction
      }
    • //Function to get onecategory with associatedsubcategories
      functiongetOneCategory($session, $category_id){
      //Get Categories
      $get_cats = "http://samsok.libris.kb.se/X?op=retrieve_categories_request&requester_ip=193.10.208.75
      &session_id=$session";
      $xml = simplexml_load_file($get_cats);
      $Base = $xml->retrieve_categories_response;
      foreach ($Base->category_info as $cat){
      $category_name = $cat->category_name;
      if($category_name == $category_id){
      echo "<fieldset><legend>".$category_name."</legend>";
    • foreach($cat->subcategory_info as $sub){
      $subcategory_name = $sub->subcategory_name;
      $subcategory_count = $sub->no_bases;
      $subcategory_seq = $sub->sequence;
      if($subcategory_name == 'ALL'){
      echo "<a href=?sequence=".$subcategory_seq."&session=".$session.">ALLA ".$category_name." databaser</a> [".ltrim($subcategory_count,0)."]<br> ";
      }else{
      echo "<a href=?sequence=".$subcategory_seq."&session=".$session.">".$subcategory_na
      me."</a> [".ltrim($subcategory_count,0)."]<br> ";
      }
      }
      echo "</fieldset>";
      }
      }
      // endfunction
      }
    • //Get all available information for onedatabase
      function getDBinfo($source_001,$session){
      $get_db = "http://samsok.libris.kb.se/X?op=source_locate_request&source_locate_filter=&requester_ip
      =193.10.208.75&locate_command=IDN=".$source_001."&view=customize&field=520&field=85641&session_id="
      .$session."&institute=JON";
      $xml = simplexml_load_file($get_db);
      $Base = $xml->source_locate_response;
      foreach ($Base->source_customize_info as $db_info){
      $db_title = $db_info->source_info->source_short_name;
      echo "<fieldset><legend>$db_title</legend> ";
    • foreach($Base->source_customize_info->record->datafield as $field){
      //echo $field->subfield;
      if($field[tag] == '520'){
      $desc = $field->subfield;
      }
      if($field[tag] == '856'){
      $url = $field->subfield;
      }
      }
      echo "<b>Beskrivning:</b> $desc<p><b>URL:</b> $url </fieldset>";
      }
      //endfunction
      }
    • functionml_search($session, $db_id, $wrd, $lang){
      $do_search = "http://samsok.libris.kb.se/X?op=find_request&wait_flag=Y&find_request_command=WRD=($w
      rd)&find_base_001=$db_id&session_id=$session";
      $xml = simplexml_load_file($do_search);
      $Base = $xml->find_response->base_info;
      $doc_count = $Base->no_of_documents;
      $set_number = $Base->set_number;
      if($doc_count >= '1'){
      if($lang == 'eng'){
      $sb_url = "http://hbopac.lingonline.jonkoping.se/opac/search_result.aspx?TextFritext=$wrd";
      echo "<li><ahref=$sb_url>Alsoavailable at the public library</a><br>";
      }else{
    • $sb_url = "http://hbopac.lingonline.jonkoping.se/opac/search_result.aspx?TextFritext=$wrd";
      echo "<li><ahref=$sb_url>Finns &auml;venp&aring; stadsbiblioteket</a><br>";
      }
      }else{
      if($lang =='eng'){
      echo "<li>Notavailable at the public library<br>";
      }else{
      echo "<li>Finns inte p&aring; stadsbiblioteket<br>";
      }
      }
      }
    • //Get database by category id
      functiongetDBbyCat($catid,$session,$cat_name){
      $get_db = "http://samsok.libris.kb.se/X?op=source_locate_request&source_locate_filter=&requester_ip
      =193.10.208.75&locate_command=WFL=".$catid."&view=customize&field=85641&session_id=".$session."&institute=JON";
      echo "<script>varnewwindow;
      functionpoptastic(url)
      {
      newwindow=window.open(url,'name','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,r
      esizable=1,width=500,height=500,left = 640,top = 325');
      if (window.focus) {newwindow.focus()}
      }
      </script><scripttype='text/javascript' src='http://193.10.208.75/exlibris/aleph/u18_1/alephe/www_f_swe/icon/prototype.js'></script>
      <fieldset><legend>$cat_name</legend>";
    • $xml = simplexml_load_file($get_db);
      $Base = $xml->source_locate_response;
      //print $get_db;
      foreach ($Base->source_customize_info as $source){
      $source_name = $source->source_info->source_short_name;
      $source_001 = $source->source_info->source_001;
      $url = $source->record->datafield->subfield;
      echo "<li>$source_name <a href=$url>Direkt till databas</a> | ";
      echo "<a href=javascript:poptastic('getDBinfo.php?session=$session&dbid=$source_001');>Mer information</a>";
      $x++;
      }
      echo "</fieldset>";
      //endfunction
      }
    • http://libris.kb.se/bibspell/spell?query=ammerica&key=XXX
      http://api.libris.kb.se/bibspell/
    • find-b-list-head-jul01
      <div id="spell"></div>
      <script language="javascript" type="text/javascript" src=”spell.js">
      </script>
    • Spell.js använder prototype.js
      var TITLE = document.URL;
      var where_is_start=TITLE.indexOf('request');
      var where_is_end=TITLE.indexOf('&find_code');
      var new_start=where_is_start+8;
      var searchword = TITLE.slice(new_start, where_is_end);
      if(searchword){
      var spinner = '<fieldset><legend>Did you mean ...?</legend><br />
      <center><img src=”ajax-loader.gif"><h2>Looking for suggestions. Please wait.</h2>
      </center></fieldset>';
      }else{
      var spinner = '';
      }
      document.getElementById("spell").innerHTML=spinner;
      new Ajax.Updater('spell', ’ spell.php',
      { method: 'get', success: 'spell', failure: 'errors', parameters:
      {URL: searchword}});
    • Spell.php
      <?php
      include ’passwords from outside the webroot';
      echo "<fieldset><legend>Did you mean ...?</legend><center><h3>";
      $term = $_GET['URL'];
      $clean_terms = urldecode($term);
      $request = 'http://libris.kb.se/bibspell/spell?query='.$term.'&key=XXX';
      $bibspell = simplexml_load_file($request);
      $sugcheck = $bibspell->suggestion->term;
      if($sugcheck){
      foreach($bibspell->suggestion->term as $suggestion){
      $suggest .= " $suggestion";
      $suggest2 .= "$suggestion+";
      }
    • Spell.php
      echo "You searched for <i><font color=red>$clean_terms</font></i><br/><br />LIBR
      IS suggests you try <a href=http://julia.hj.se/F/?func=find-b&request=$suggest2&
      find_code=WRD&adjacent=N&x=53&y=1&con_lng=eng>$suggest</a><br /><br />";
      }else{
      echo "LIBRIS has no suggestions for you.<br /><br />";
      }
    • Spell.php
      $request = 'http://search.yahooapis.com/WebSearchService/V1/spellingSuggestion?a
      ppid='.$yahoo_key.'&query='.$term.'';
      $xml = simplexml_load_file($request);
      $description = $xml->Result;
      if (empty($xml->Result)){
      echo "<p>Yahoo! has no suggestion for you";
      }else{
    • Spell.php
      foreach ($xml->Result as $suggestion) {
      $suggest = $xml->Result;
      $suggest2 = http_build_query($suggest);
      $suggest3 = str_replace('0=','',$suggest2);
      echo "<p>Yahoo! suggests you try <a href=http://julia.hj.se/F/?func=find-b&reque
      st=$suggest3&find_code=WRD&adjacent=N&x=53&y=1&con_lng=eng>$suggest</a>";
      }
      }
      echo '</h3><br /><div align="right"><a href="http://developer.yahoo.com/">
      <img src="http://julia.hj.se/exlibris/aleph/u18_1/alephe/www_f_tst/icon/websrv_1
      20_1.gif" border="0">
      </a><br /><a href="http://libris.kb.se"><img src=http://julia.hj.se/exlibris/ale
      ph/u18_1/alephe/www_f_tst/icon/libris_logotyp.gif border=0></a></div>
      </center></fieldset>';
      ?>
    • <linkrel="alternate" type="application/rdf+xml" title="RDF Representation" href="http://libris.kb.se/data/bib/7156538?format=application%2Frdf%2Bxml" >
    • Introduktion till API:er, webbtjänster &
      att integrera LIBRIS tjänster i OPAC
      [DETTA ÄR SLUTET]
      Daniel Forsman
      Chalmers bibliotek
      Att använda LIBRIS öppna infrastruktur
      20 maj 2010