Your SlideShare is downloading. ×
0
Att använda LIBRIS öppna infrastruktur<br />Högskolan i Jönköping<br />20-21 maj 2010<br />
#librisAPIws<br />
20 maj<br />12.00 – 12.10 Inledning<br />12.10 – 13.00 Tankarna bakom LIBRIS öppna infrastruktur<br />13.00 – 13.30 Introd...
Introduktion till API:er, webbtjänster &<br />att integrera LIBRIS tjänster i OPAC<br />Daniel Forsman<br />Chalmers bibli...
”Basic scholarly information usepracticeshaveshiftedrapidlyin recent years,<br />and as a result the academiclibrary is in...
LIBRIS<br />ILS<br />OPAC<br />CAT<br />ACQ<br />ILL<br />CAT<br />OPAC<br />Patron<br />CIRC<br />
OA <br />Arkiv<br />Linked data<br />Fed. search<br />Link<br />Resolv.<br />ERM<br />LIBRIS<br />ILS<br />Aggr.<br />Reko...
Lokalt<br />Globalt<br />Kontext<br />SaaS<br />Nationellt<br />Individ<br />Konvergens<br />Paradigm<br />skifte<br />Ins...
Öppenhet i en tjänstebaserad värld<br />Open standards<br />Open Access<br />Open educationalresources<br />Open source<br...
Webben har blivit en plattform där gränssnitten frikopplas från systemen och de underliggande tjänsterna<br />Decoupling o...
API?<br />”An ApplicationProgramming Interface (API) is an interface implemented by a software program whichenables it to ...
Webbtjänst?<br />“A Web service is a software system designed to support interoperable  machine­to-machine interaction ove...
SOAP & REST<br />REST –Representational State Transfer -  är en arkitektur för att tillhandahålla tjänster för maskin till...
AJAX är en akronym för Asynchronous JavaScript and XML (Asynkron JavaScript och XML) som är ett samlingsnamn för ett antal...
Vad behöver man?<br />För att fånga upp element på en webbsida manipulerar man DOM<br />Med XMLhttpRequest kan man skicka ...
Varför integrera webbtjänster i OPAC?<br />By exploringweb services and new technology wegain first hand experiencemakingu...
OPAC:en är inte decoupled …<br />Men de flesta tillåter att man stoppar in javascript<br />Javascript tillsammans med en ”...
Hooki full-999-body<br /><!-- filename: full-999-body --><br /><span id="$0100”>$0200<br /><span><br /><br /><br />
CSS selectors<br />Javascript<br />document.getElementById()<br />jQuery : jQuery('#id')<br /><divid="myDiv">id="myDiv"</d...
//putissn in xissn variable<br />var xissn=document.getElementById("ISSN");<br />//pass issn to backend script, echoresult...
OPAC -> DOM manipulation -> AJAX -> PHP -> Webbtjänst  -> OPAC<br />
http://libris.kb.se/xsearch?query=word+of+mouth+marketing&format=mods<br />
Att fånga söktermer<br /><script type="text/javascript"> <br />//Retreive and store webpage URL <br />var TITLE = document...
new Ajax.Updater(’libris', ’libris.php', {method: 'get', success: ’libris',<br />failure: 'errors', parameters: {librister...
<?php<br />echo ’<STYLE TYPE="text/css"><br />a {text-decoration:none;}<br />font-family:verdana,arial,helvetica,sans-seri...
if (empty($Base->mods)){ <br />//do nada<br />}else{<br />echo "<h2>LIBRIS Results<br><i>National union catalog</i></h2><o...
http://libris.kb.se/xsearch?database=swepub&query=agriculture+economy&format=mods<br />
//Start Swepub<br />$SWErequest = 'http://libris.kb.se/xsearch?database=swepub&query='.$word.'&format=mods';<br />$SWExml ...
$author_array = array();<br />foreach ($SWEitem->name as $SWEau){<br />array_push($author_array, $SWEau->namePart);<br /> ...
http://uppsok.libris.kb.se/sru/uppsok?&operation=searchRetrieve&query=%22information+retrieval%22&maximumRecords=10&record...
<?php<br />error_reporting(0);<br />$word=$_GET["uppsokterm"];<br />$request = "http://uppsok.libris.kb.se/sru/uppsok?&ope...
$x = "1";<br />foreach ($Base->record as $item) {<br />echo "<li><ahref=";<br />echo $item->recordData->dc->identifier;<br...
http://samsok.libris.kb.se/X?op=login_request&user_name=UID&user_password=PW<br />
http://samsok.libris.kb.se/X?op=find_request&wait_flag=Y&find_request_command=WRD=%28america%29&find_base_001=LIB32223&ses...
new Ajax.Updater(’metalib', '/php/metalib_e.php', { method: 'get', success: ’metalib', <br />failure: 'errors', parameters...
<?php<br />//Turnofferrorreporting<br />error_reporting(0);<br />include ’/file_outside_webroot/with/user/credentials.php'...
$xmlDoc = new DOMDocument();<br />$xmlDoc->load("http://samsok.libris.kb.se/X?op=find_request&wait_flag=Y&find_req<br />ue...
 echo "<li><a href=http://www.bibl.hj.se/databas/proxy.php?url=http://samsok.<br />libris.kb.se/V/$session_id?func=meta-3&...
http://link.libris.kb.se/sfxjon?sid=ALEPH:JUL01&issn=1501-7419&sfx.response_type=simplexml<br />
<script type="text/javascript"> <br />var elem = document.getElementById("ISBN"); <br />elem.innerHTML = elem.innerHTML.re...
try{ var xissn=document.getElementById("ISSN"); <br />…<br />if(xissn){ var spinner = '<fieldset><legend>e-JULIAservices</...
 // removeallwhitespace<br />xissn.innerHTML = xissn.innerHTML.replace(/s/g, "" );<br />// remove / <br />var IssnRegExp =...
SFX API<br /><?php<br />//Receive ISSN from ALEPH OPAC<br />$issn=$_GET["issn"];<br />$openurl = "http://link.libris.kb.se...
SFX API<br />//Loop through results and present selected targets<br />foreach ($Base->target as $target) {<br /> if($targe...
SFX API<br /> if($target->service_type == 'getAbstract'){<br />   echo "<li><a href=". $proxy.$target->target_url .">Abstr...
ticTOCs<br />JULIA works with flat txtfile from JISC, converts it to XML and<br />query it as a local service (butanyoneco...
try{ <br />var xissn=document.getElementById("ISSN"); <br />var x2isbn=document.getElementById("ISBN"); <br />if(xissn){ <...
if(x2isbn){ <br />new Ajax.Updater('eJULIA', ’sfx_sv.php', { method: 'get', success: 'eJULIA', failure: 'errors', paramete...
//getSession, creates the session with the x-server, user/password<br />functiongetSession($u,$p){<br />//everything is re...
//Function to list all MetaLibcategories<br />functiongetAllCategories($session){<br />//Definecall URL<br />$get_cats = "...
if($subcategory_name == 'ALL'){<br />echo "<a href=getDBbyCat.php?sequence=".$subcategory_seq."&session=".$session."&nam<b...
//Function to get onecategory with associatedsubcategories<br />functiongetOneCategory($session, $category_id){<br />//Get...
foreach($cat->subcategory_info as $sub){<br />                $subcategory_name = $sub->subcategory_name;<br />           ...
//Get all available information for onedatabase<br />function getDBinfo($source_001,$session){<br />$get_db = "http://sams...
foreach($Base->source_customize_info->record->datafield as $field){<br />        //echo $field->subfield;<br />if($field[t...
functionml_search($session, $db_id, $wrd, $lang){<br />$do_search = "http://samsok.libris.kb.se/X?op=find_request&wait_fla...
$sb_url = "http://hbopac.lingonline.jonkoping.se/opac/search_result.aspx?TextFritext=$wrd";<br />echo "<li><ahref=$sb_url>...
//Get database by category id<br />functiongetDBbyCat($catid,$session,$cat_name){<br />$get_db = "http://samsok.libris.kb....
$xml = simplexml_load_file($get_db);<br />$Base = $xml->source_locate_response;<br />//print $get_db;<br />foreach ($Base-...
http://libris.kb.se/bibspell/spell?query=ammerica&key=XXX<br />http://api.libris.kb.se/bibspell/<br />
find-b-list-head-jul01<br /><div id="spell"></div> <br /><script language="javascript" type="text/javascript" src=”spell.j...
Spell.js använder prototype.js<br />var TITLE = document.URL;  <br />var where_is_start=TITLE.indexOf('request');  <br />v...
Spell.php<br /><?php<br />include ’passwords from outside the webroot';<br />echo "<fieldset><legend>Did you mean ...?</le...
Spell.php<br />echo "You searched for <i><font color=red>$clean_terms</font></i><br/><br />LIBR<br />IS suggests you try <...
Spell.php<br />$request = 'http://search.yahooapis.com/WebSearchService/V1/spellingSuggestion?a<br />ppid='.$yahoo_key.'&q...
Spell.php<br />foreach ($xml->Result as $suggestion) {<br />$suggest = $xml->Result;<br />$suggest2 = http_build_query($su...
<linkrel="alternate" type="application/rdf+xml" title="RDF Representation" href="http://libris.kb.se/data/bib/7156538?form...
Introduktion till API:er, webbtjänster &<br />att integrera LIBRIS tjänster i OPAC<br />[DETTA ÄR SLUTET]<br />Daniel Fors...
Upcoming SlideShare
Loading in...5
×

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

6,035

Published on

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

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
6,035
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
19
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

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

  1. 1. Att använda LIBRIS öppna infrastruktur<br />Högskolan i Jönköping<br />20-21 maj 2010<br />
  2. 2. #librisAPIws<br />
  3. 3. 20 maj<br />12.00 – 12.10 Inledning<br />12.10 – 13.00 Tankarna bakom LIBRIS öppna infrastruktur<br />13.00 – 13.30 Introduktion till API:er, webbtjänster och LIBRIS system<br />13.30 – 14.30 Integrera LIBRIS tjänster i din OPAC<br />14.30 – 15.00 Paus<br />15.00 – 16.00 Integrera LIBRIS tjänster i din webbplats <br />16.00 – 17.00 Att skapa en söktjänst med LIBRIS som komponent<br />17.00 – Gruppdiskussioner på temat Vad skulle du vilja göra med LIBRIS API:er och tjänster?<br />21 maj<br />09.00 – 09.30 Återkoppling till gårdagens diskussion<br />09.30 – 10.00 SUB:s arbete med LIBRIS API:er<br />10.00 – 10.20 Paus<br />10.20 – 11.20 Hur kommer LIBRIS öppna infrastruktur att utvecklas, vad kan vi förvänta oss i framtiden?<br />11.20 – 12.00 Öppna frågor till en panel med de som presenterat under dagarna<br />12.00 – 12.30 Hur går vi vidare, uppföljning, avrundning och avslutning<br />
  4. 4. Introduktion till API:er, webbtjänster &<br />att integrera LIBRIS tjänster i OPAC<br />Daniel Forsman<br />Chalmers bibliotek<br />Att använda LIBRIS öppna infrastruktur<br />20 maj 2010<br />
  5. 5. ”Basic scholarly information usepracticeshaveshiftedrapidlyin recent years,<br />and as a result the academiclibrary is increasinglybeingdisintermediated from the<br />discoveryprocess, riskingirrelevancein one of itscorefunctionalareas”<br />Ithaka S+R 2009 FacultySurvey Report<br />The future of libraries? Technology has created a verydifferent contextfor the <br />missions of academic and research libraries<br />No Brief Candle, DaphneeRentfrow<br />
  6. 6. LIBRIS<br />ILS<br />OPAC<br />CAT<br />ACQ<br />ILL<br />CAT<br />OPAC<br />Patron<br />CIRC<br />
  7. 7. OA <br />Arkiv<br />Linked data<br />Fed. search<br />Link<br />Resolv.<br />ERM<br />LIBRIS<br />ILS<br />Aggr.<br />Rekommendation<br />Proxy & SSO<br />OPAC<br />CAT<br />ACQ<br />ILL<br />CAT<br />RDF<br />ILL<br />OPAC<br />Patron<br />Aggr. DB<br />Discovery<br />CIRC<br />Integratedsearch<br />Amazon<br />Google<br />Enskild DB<br />OER<br />Digitalisering<br />
  8. 8. Lokalt<br />Globalt<br />Kontext<br />SaaS<br />Nationellt<br />Individ<br />Konvergens<br />Paradigm<br />skifte<br />Institution<br />System<br />Bransch<br />glidning<br />OS<br />Sam<br />arbete<br />Digitalisering<br />Institutionella arkiv<br />Linked data<br />API<br />Mobil<br />Data<br />OA<br />Open<br />Data<br />Kanaler<br />Webb<br />Licens<br />Bib. service<br />Lokaler<br />DaaS<br />VLE<br />
  9. 9. Öppenhet i en tjänstebaserad värld<br />Open standards<br />Open Access<br />Open educationalresources<br />Open source<br />Open platform<br />Open data<br />Garanti för teoretisk valfrihet<br />
  10. 10.
  11. 11. Webben har blivit en plattform där gränssnitten frikopplas från systemen och de underliggande tjänsterna<br />Decoupling of frontend from backend<br />WorldcatAPI, XISBN, LibraryThing for Libraries , LIBRIS Xsearch, MetaLib | Aleph X-server, SFX API, EbscoHost Integration Toolkit, <br />ISI Web Services, Amazon, SRU/W, RDF | Linked Data, Google Code, Flickr API, Yahoo! Developer Network, Yahoo! Pipes … … … <br />
  12. 12. API?<br />”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”<br />// Wikipedia – ApplicationProgramming Interface<br />
  13. 13. Webbtjänst?<br />“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.“ <br />// W3C definition<br />Web services are frequently just Internet Application Programming <br />Interfaces (API) that can be accessed over a network, such as the <br />Internet, and executed on a remote system hosting the requested <br />services.  // Wikipedia – Web service<br />
  14. 14. SOAP & REST<br />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.<br />// http://sv.wikipedia.org/wiki/Representational_State_Transfer<br />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<br />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<br />// http://www.programmera.net/webservice/soap.php<br />
  15. 15. 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.<br />XMLHttpRequest-objektet, som tillåter JavaScript på en webbsida att göra anrop till webbservern utan att sidan laddas om. <br />DOM (DocumentObjectModel) vilket tillåter JavaScript att skriva om innehåll på den aktuella sidan.<br />//http://sv.wikipedia.org/wiki/AJAX<br />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.<br />// http://sv.wikipedia.org/wiki/Document_Object_Model<br />
  16. 16. Vad behöver man?<br />För att fånga upp element på en webbsida manipulerar man DOM<br />Med XMLhttpRequest kan man skicka och få tillbaka data till webbläsaren utan att ladda om den<br />Javascript bibliotek som jQuery och Prototype gör detta enkelt<br />JSON-formatet gör att man kan läsa in data direkt i klienten via javascript<br />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.<br />// http://www.json.org/<br />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.<br />Säkerhetsinställningarna för XMLhttpRequest gör att man inte kan anropa ”externa” servrar,<br />anrop måste ske lokalt eller via proxy<br />Mina exempel bygger i huvudsak på PHP och Prototype<br />
  17. 17. Varför integrera webbtjänster i OPAC?<br />By exploringweb services and new technology wegain first hand experiencemakingusstrongercustomers and development partners <br />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.<br />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.<br />Att kunna visa lokala resurser i ett regionalt, nationellt och globalt sammanhang<br />
  18. 18. OPAC:en är inte decoupled …<br />Men de flesta tillåter att man stoppar in javascript<br />Javascript tillsammans med en ”hook” kan agera med ett serverside script<br />XML format spelar ingen roll för mig … metoden går att återanvända genom att använda PHP:s<br />färdiga funktioner för att göra anrop och bearbeta XML<br />
  19. 19.
  20. 20. Hooki full-999-body<br /><!-- filename: full-999-body --><br /><span id="$0100”>$0200<br /><span><br /><br /><br />
  21. 21. CSS selectors<br />Javascript<br />document.getElementById()<br />jQuery : jQuery('#id')<br /><divid="myDiv">id="myDiv"</div> <script>$("#myDiv").css("border","3px solid red");</script><br />http://api.jquery.com/category/selectors/<br />Prototype : $$('#contents'); <br />getElementsbyTagName<br />getElementsbyClassName<br />http://api.prototypejs.org/language/dollardollar/ <br />
  22. 22. //putissn in xissn variable<br />var xissn=document.getElementById("ISSN");<br />//pass issn to backend script, echoresult in diveJULIA<br />new Ajax.Updater('eJULIA', ’sfx.php', { method: 'get', success: 'eJULIA', failure: 'errors', parameters: {issn: xissn.innerHTML} <br />
  23. 23.
  24. 24. OPAC -> DOM manipulation -> AJAX -> PHP -> Webbtjänst -> OPAC<br />
  25. 25.
  26. 26. http://libris.kb.se/xsearch?query=word+of+mouth+marketing&format=mods<br />
  27. 27. Att fånga söktermer<br /><script type="text/javascript"> <br />//Retreive and store webpage URL <br />var TITLE = document.URL; <br />if(TITLE.search("request") > -1) { <br />//Find position of request in URL <br />var where_is_start1=TITLE.indexOf('request'); <br />//Find the position of &find_code<br />if(TITLE.search("&x=") > -1) { <br />var where_is_end1=TITLE.indexOf('&x='); <br />}else{ <br />var where_is_end1=TITLE.indexOf('&find_code='); <br />} <br />//Define a the position wheresearchwords start - at the end of request<br />var new_start=where_is_start+8; <br />//Put the searchwords in a string, defined by start and end position <br />searchword = TITLE.slice(new_start, where_is_end); <br />} <br /></script> <br />
  28. 28. new Ajax.Updater(’libris', ’libris.php', {method: 'get', success: ’libris',<br />failure: 'errors', parameters: {libristerm: searchword} });<br />
  29. 29. <?php<br />echo ’<STYLE TYPE="text/css"><br />a {text-decoration:none;}<br />font-family:verdana,arial,helvetica,sans-serif;<br /></style>';<br />error_reporting(0);<br />$word=$_GET["libristerm"];<br />$request = 'http://libris.kb.se/xsearch?query='.$word.'&format=mods';<br />$xml = simplexml_load_file($request);<br />$Base = $xml->modsCollection;<br />
  30. 30. if (empty($Base->mods)){ <br />//do nada<br />}else{<br />echo "<h2>LIBRIS Results<br><i>National union catalog</i></h2><ol>";<br />$x = "1";<br />foreach ($Base->mods as $item) {<br />echo "<li><ahref=http://libris.kb.se/hitlist?d=libris&q=";<br />echo $word;<br />echo "&f=simp&spell=true&hist=true&p=1 STYLE='text-decoration: none;'>";<br />echo $item->titleInfo->title;<br />echo "</a> ";<br />echo $item->name->namePart;<br />echo "</li>";<br /> $x++;<br />} <br />echo "</ol><divalign=right><br /><a href=http://libris.kb.se/hitlist?d=libris&q<br />=$word&f=simp&spell=true&hist=true&p=1>View results in LIBRIS</a></div>";<br />}<br />?><br />
  31. 31.
  32. 32. http://libris.kb.se/xsearch?database=swepub&query=agriculture+economy&format=mods<br />
  33. 33. //Start Swepub<br />$SWErequest = 'http://libris.kb.se/xsearch?database=swepub&query='.$word.'&format=mods';<br />$SWExml = simplexml_load_file($SWErequest);<br />$SWEBase = $SWExml->modsCollection;<br />if (empty($SWEBase->mods)){<br />//do nada<br />}else{<br />echo "<h2>SwePub - Tr&auml;fflista</h2><ol>";<br />$SWEx = "1";<br />foreach ($SWEBase->mods as $SWEitem) {<br />echo "<li><ahref=";<br />echo $SWEitem->identifier;<br />echo " STYLE='text-decoration: none;'>";<br />echo $SWEitem->titleInfo->title;<br />echo "</a> ";<br />
  34. 34. $author_array = array();<br />foreach ($SWEitem->name as $SWEau){<br />array_push($author_array, $SWEau->namePart);<br /> }<br />$au_count = count($author_array);<br />if ($au_count >= 2){<br />echo "$author_array[0] et al";<br />}else{<br />echo "$author_array[0]";<br />}<br />echo "</li>";<br /> $SWEx++;<br />}<br />echo "</ol><divalign=right><br /><a href=http://swepub.kb.se/hitlist?d=swepub&q=$word&f=simp&spell=true&hist=<br />true&p=1>Till tr&auml;fflista i SwePub</a></div>";<br />}<br />?><br />
  35. 35.
  36. 36. http://uppsok.libris.kb.se/sru/uppsok?&operation=searchRetrieve&query=%22information+retrieval%22&maximumRecords=10&recordSchema=dc&x-render-output=xml<br />
  37. 37. <?php<br />error_reporting(0);<br />$word=$_GET["uppsokterm"];<br />$request = "http://uppsok.libris.kb.se/sru/uppsok?&operation=searchRetrieve&query=%22$word%22&maximumRecords=10&recordSchema=dc&x-render-output=xml";<br />$xml = simplexml_load_file($request);<br />$Base = $xml->records;<br />if (empty($Base->record)){ <br />//Wecouldsaysomething … men nej<br />}else{<br />echo "<h2>Upps&ouml;k <br><i>Uppsatser & Examensarbeten</i></h2><ol>";<br />
  38. 38. $x = "1";<br />foreach ($Base->record as $item) {<br />echo "<li><ahref=";<br />echo $item->recordData->dc->identifier;<br />echo " STYLE='text-decoration: none;'>";<br />echo $item->recordData->dc->title;<br />echo "</a> ";<br />echo $item->recordData->dc->creator;<br />echo "</li>";<br /> $x++;<br />} <br />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 <br />tr&auml;fflista i Upps&ouml;k</a></div>";<br />}<br />?><br />
  39. 39.
  40. 40. http://samsok.libris.kb.se/X?op=login_request&user_name=UID&user_password=PW<br />
  41. 41. 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<br />
  42. 42. new Ajax.Updater(’metalib', '/php/metalib_e.php', { method: 'get', success: ’metalib', <br />failure: 'errors', parameters: {name: searchword} });<br />
  43. 43. <?php<br />//Turnofferrorreporting<br />error_reporting(0);<br />include ’/file_outside_webroot/with/user/credentials.php';<br />$wrd = $_GET['name'];<br />$newrd = str_replace('?undefined', '', $wrd);<br />$query_string = 'SEARCH_ANY=' . urlencode($newrd) . '';<br />$dom = new DomDocument();<br />$dom->load("http://samsok.libris.kb.se/X?op=login_request&user_name=$mluid&user_<br />password=$mlpw");<br />$sessions = $dom->getElementsByTagName("session_id");<br />foreach($sessions as $session) {<br />$session_id = $session->textContent;<br />
  44. 44. $xmlDoc = new DOMDocument();<br />$xmlDoc->load("http://samsok.libris.kb.se/X?op=find_request&wait_flag=Y&find_req<br />uest_command=WRD=($newrd)&find_base_001=LIB40723&find_base_001=LIB39584&<br />session_id=$session_id");<br />$searchNode = $xmlDoc->getElementsByTagName( "base_info" );<br />echo"<h2>Metasearch</h2><br />&nbsp;&nbsp;&nbsp;Results from metasearch via Sam<br />s&ouml;k</i><ul>";<br />foreach( $searchNode as $searchNode )<br />{<br /> $xmlDate = $searchNode->getElementsByTagName( "no_of_documents" );<br /> $count = ltrim($valueDate = $xmlDate->item(0)->nodeValue, "0");<br />if($count == ''){$count = "0";}<br /> $xmlAuthorID = $searchNode->getElementsByTagName( "full_name" );<br /> $valueAuthorID = $xmlAuthorID->item(0)->nodeValue;<br /> $xmlSet_number = $searchNode->getElementsByTagName( "set_number" );<br /> $valueSet_number = $xmlSet_number->item(0)->nodeValue;<br />
  45. 45. echo "<li><a href=http://www.bibl.hj.se/databas/proxy.php?url=http://samsok.<br />libris.kb.se/V/$session_id?func=meta-3&set_number=$valueSet_number STYLE='text-d<br />ecoration: none;'>$valueAuthorID : $count</a></li>"; <br />}<br />echo "</ul><br />";<br />}<br />?><br />
  46. 46.
  47. 47.
  48. 48. http://link.libris.kb.se/sfxjon?sid=ALEPH:JUL01&issn=1501-7419&sfx.response_type=simplexml<br />
  49. 49. <script type="text/javascript"> <br />var elem = document.getElementById("ISBN"); <br />elem.innerHTML = elem.innerHTML.replace(/[().-s,]/g, ""); <br />elem.innerHTML = elem.innerHTML.replace(/[^d]/g, ""); <br />if(elem){ <br />new Ajax.Updater('eJULIA', '/php/sfx_sv.php', { method: 'get', success: 'eJULIA', failure: 'errors', parameters: {isbn: elem.innerHTML}}); <br />} <br /></script> <br />
  50. 50. try{ var xissn=document.getElementById("ISSN"); <br />…<br />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>'; <br />…<br />document.getElementById("eJULIA").innerHTML=spinner; <br />
  51. 51. // removeallwhitespace<br />xissn.innerHTML = xissn.innerHTML.replace(/s/g, "" );<br />// remove / <br />var IssnRegExp = new RegExp("/","g");<br />xissn.innerHTML = xissn.innerHTML.replace(IssnRegExp, ""); <br />// remove <b> <br />xissn.innerHTML = xissn.innerHTML.replace(/<b>/g, "" );<br />new Ajax.Updater('eJULIA', ’sfx.php', { method: 'get', success: 'eJULIA', failure: 'errors', parameters: {issn: xissn.innerHTML} <br />
  52. 52. SFX API<br /><?php<br />//Receive ISSN from ALEPH OPAC<br />$issn=$_GET["issn"];<br />$openurl = "http://link.libris.kb.se/sfxjon?sid=ALEPH:JUL01&issn=$issn&sfx.response_type=simplexml";<br />//Make the call to SFX and loadresults<br />$xml = simplexml_load_file($openurl);<br />//Targets base<br />$Base = $xml->targets;<br />//HTML formating<br />echo "<fieldset><legend>e-JULIAlinkservices</legend><ul>";<br />
  53. 53. SFX API<br />//Loop through results and present selected targets<br />foreach ($Base->target as $target) {<br /> if($target->service_type == 'getHolding' ){<br /> echo "<li><a href=". $proxy.$target->target_url .">Search for title in ". $target->target_public_name . "</a></li> ";<br /> }<br /> if($target->service_type == 'getCitedJournal' ){<br /> echo "<li><a href=". $proxy.$target->target_url .">Search for ". $target->target_public_name . "</<br />a></li> ";<br /> }<br /> if($target->service_type == 'getFullTxt'){<br /> echo "<li><a href=". $proxy.$target->target_url .">Fulltext available from ". $target->target_public_name . "</a></li> ";<br /> }<br />
  54. 54. SFX API<br /> if($target->service_type == 'getAbstract'){<br /> echo "<li><a href=". $proxy.$target->target_url .">Abstract available from ". $target->target_pub<br />lic_name . "</a></li> ";<br /> }<br /> if($target->service_type == 'getTOC'){<br /> echo "<li><a href=". $proxy.$target->target_url .">Table of content available from ". $target->ta<br />rget_public_name . "</a></li> ";<br /> }<br />}<br />?><br />
  55. 55. ticTOCs<br />JULIA works with flat txtfile from JISC, converts it to XML and<br />query it as a local service (butanyonecould …).<br />journalTOCsnow offer a API that you canuseinstead of downloading<br />a txtfile.<br />http://www.journaltocs.hw.ac.uk/index.php?action=api<br />
  56. 56. try{ <br />var xissn=document.getElementById("ISSN"); <br />var x2isbn=document.getElementById("ISBN"); <br />if(xissn){ <br />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>'; <br />}else if(x2isbn){ <br />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>'; <br />}else{ <br />var spinner = ''; <br />} <br />document.getElementById("eJULIA").innerHTML=spinner; <br />
  57. 57. if(x2isbn){ <br />new Ajax.Updater('eJULIA', ’sfx_sv.php', { method: 'get', success: 'eJULIA', failure: 'errors', parameters: {isbn: x2isbn.innerHTML}}); <br />}<br />else{ <br />xissn.innerHTML = xissn.innerHTML.replace(/s/g, "" ); // remove all whitespace<br />var IssnRegExp = new RegExp("/","g"); <br />xissn.innerHTML = xissn.innerHTML.replace(IssnRegExp, ""); // remove / <br />xissn.innerHTML = xissn.innerHTML.replace(/<b>/g, "" ); // remove <b> <br />new Ajax.Updater('eJULIA', ’sfx_dev.php', { method: 'get', success: 'eJULIA', failure: 'errors', parameters: {issn: xissn.innerHTML} <br />}); <br />} <br />} <br />catch(err){ <br />} <br />
  58. 58. //getSession, creates the session with the x-server, user/password<br />functiongetSession($u,$p){<br />//everything is returned in utf-8 make sure wehave a utf-8 encoding<br />//header('Content-Type: text/html; charset=UTF-8');<br />//Definecallerurl<br />$get_session = "http://samsok.libris.kb.se/X?op=login_request&user_name=".$u."&user_password=".$p."<br />";<br />//Make call<br />$xml = simplexml_load_file($get_session);<br />//XML base<br />$Base = $xml->login_response;<br />//Define the session variable<br />$session = $Base->session_id;<br />//functionreturns session id<br />return $session;<br />}<br />
  59. 59. //Function to list all MetaLibcategories<br />functiongetAllCategories($session){<br />//Definecall URL<br />$get_cats = "http://samsok.libris.kb.se/X?op=retrieve_categories_request&requester_ip=193.10.208.75<br />&session_id=$session";<br />//Make call<br />$xml = simplexml_load_file($get_cats);<br />//Define XML base<br />$Base = $xml->retrieve_categories_response;<br />//Loop througheverycategory, putcategoryname in variable.<br />foreach ($Base->category_info as $cat){<br /> $category_name = $cat->category_name;<br />echo "<fieldset><legend>".$category_name."</legend>";<br /> //Loop throughlooking for subcategories<br />foreach($cat->subcategory_info as $sub){<br /> $subcategory_name = $sub->subcategory_name;<br /> $subcategory_count = $sub->no_bases;<br /> $subcategory_seq = $sub->sequence;<br />
  60. 60. if($subcategory_name == 'ALL'){<br />echo "<a href=getDBbyCat.php?sequence=".$subcategory_seq."&session=".$session."&nam<br />e=".$subcategory_name.">ALLA ".$category_name." databaser</a> [".ltrim($subcategory_count,0)."]<br><br /> ";<br /> }else{<br />echo "<a href=getDBbyCat.php?sequence=".$subcategory_seq."&session=".$session."&nam<br />e=".$subcategory_name.">".$subcategory_name."</a> [".ltrim($subcategory_count,0)."]<br> ";<br /> }<br /> }<br />echo "</fieldset>";<br />}<br />// endfunction<br />} <br />
  61. 61. //Function to get onecategory with associatedsubcategories<br />functiongetOneCategory($session, $category_id){<br />//Get Categories<br />$get_cats = "http://samsok.libris.kb.se/X?op=retrieve_categories_request&requester_ip=193.10.208.75<br />&session_id=$session";<br />$xml = simplexml_load_file($get_cats);<br />$Base = $xml->retrieve_categories_response;<br />foreach ($Base->category_info as $cat){<br /> $category_name = $cat->category_name;<br />if($category_name == $category_id){<br />echo "<fieldset><legend>".$category_name."</legend>";<br />
  62. 62. foreach($cat->subcategory_info as $sub){<br /> $subcategory_name = $sub->subcategory_name;<br /> $subcategory_count = $sub->no_bases;<br /> $subcategory_seq = $sub->sequence;<br />if($subcategory_name == 'ALL'){<br />echo "<a href=?sequence=".$subcategory_seq."&session=".$session.">ALLA ".$category_name." databaser</a> [".ltrim($subcategory_count,0)."]<br> ";<br /> }else{<br />echo "<a href=?sequence=".$subcategory_seq."&session=".$session.">".$subcategory_na<br />me."</a> [".ltrim($subcategory_count,0)."]<br> ";<br /> }<br /> }<br />echo "</fieldset>";<br /> }<br />}<br />// endfunction<br />}<br />
  63. 63. //Get all available information for onedatabase<br />function getDBinfo($source_001,$session){<br />$get_db = "http://samsok.libris.kb.se/X?op=source_locate_request&source_locate_filter=&requester_ip<br />=193.10.208.75&locate_command=IDN=".$source_001."&view=customize&field=520&field=85641&session_id="<br />.$session."&institute=JON";<br />$xml = simplexml_load_file($get_db);<br />$Base = $xml->source_locate_response;<br />foreach ($Base->source_customize_info as $db_info){<br />$db_title = $db_info->source_info->source_short_name;<br />echo "<fieldset><legend>$db_title</legend> ";<br />
  64. 64. foreach($Base->source_customize_info->record->datafield as $field){<br /> //echo $field->subfield;<br />if($field[tag] == '520'){<br /> $desc = $field->subfield;<br /> }<br />if($field[tag] == '856'){<br /> $url = $field->subfield; <br /> }<br /> }<br />echo "<b>Beskrivning:</b> $desc<p><b>URL:</b> $url </fieldset>";<br />}<br />//endfunction<br />}<br />
  65. 65. functionml_search($session, $db_id, $wrd, $lang){<br />$do_search = "http://samsok.libris.kb.se/X?op=find_request&wait_flag=Y&find_request_command=WRD=($w<br />rd)&find_base_001=$db_id&session_id=$session";<br />$xml = simplexml_load_file($do_search);<br />$Base = $xml->find_response->base_info;<br />$doc_count = $Base->no_of_documents;<br />$set_number = $Base->set_number;<br />if($doc_count >= '1'){<br />if($lang == 'eng'){<br /> $sb_url = "http://hbopac.lingonline.jonkoping.se/opac/search_result.aspx?TextFritext=$wrd";<br />echo "<li><ahref=$sb_url>Alsoavailable at the public library</a><br>";<br /> }else{<br />
  66. 66. $sb_url = "http://hbopac.lingonline.jonkoping.se/opac/search_result.aspx?TextFritext=$wrd";<br />echo "<li><ahref=$sb_url>Finns &auml;venp&aring; stadsbiblioteket</a><br>";<br /> }<br />}else{<br />if($lang =='eng'){<br />echo "<li>Notavailable at the public library<br>";<br /> }else{<br />echo "<li>Finns inte p&aring; stadsbiblioteket<br>";<br /> }<br />}<br />}<br />
  67. 67. //Get database by category id<br />functiongetDBbyCat($catid,$session,$cat_name){<br />$get_db = "http://samsok.libris.kb.se/X?op=source_locate_request&source_locate_filter=&requester_ip<br />=193.10.208.75&locate_command=WFL=".$catid."&view=customize&field=85641&session_id=".$session."&institute=JON";<br />echo "<script>varnewwindow;<br />functionpoptastic(url)<br />{<br /> newwindow=window.open(url,'name','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,r<br />esizable=1,width=500,height=500,left = 640,top = 325');<br />if (window.focus) {newwindow.focus()}<br />}<br /></script><scripttype='text/javascript' src='http://193.10.208.75/exlibris/aleph/u18_1/alephe/www_f_swe/icon/prototype.js'></script> <br /><fieldset><legend>$cat_name</legend>";<br />
  68. 68. $xml = simplexml_load_file($get_db);<br />$Base = $xml->source_locate_response;<br />//print $get_db;<br />foreach ($Base->source_customize_info as $source){<br /> $source_name = $source->source_info->source_short_name;<br /> $source_001 = $source->source_info->source_001;<br /> $url = $source->record->datafield->subfield;<br />echo "<li>$source_name <a href=$url>Direkt till databas</a> | ";<br />echo "<a href=javascript:poptastic('getDBinfo.php?session=$session&dbid=$source_001');>Mer information</a>";<br /> $x++;<br />}<br />echo "</fieldset>";<br />//endfunction<br />}<br />
  69. 69.
  70. 70.
  71. 71.
  72. 72. http://libris.kb.se/bibspell/spell?query=ammerica&key=XXX<br />http://api.libris.kb.se/bibspell/<br />
  73. 73. find-b-list-head-jul01<br /><div id="spell"></div> <br /><script language="javascript" type="text/javascript" src=”spell.js"><br /></script> <br />
  74. 74. Spell.js använder prototype.js<br />var TITLE = document.URL; <br />var where_is_start=TITLE.indexOf('request'); <br />var where_is_end=TITLE.indexOf('&find_code'); <br />var new_start=where_is_start+8; <br />var searchword = TITLE.slice(new_start, where_is_end); <br />if(searchword){ <br /> var spinner = '<fieldset><legend>Did you mean ...?</legend><br /><br /><center><img src=”ajax-loader.gif"><h2>Looking for suggestions. Please wait.</h2><br /></center></fieldset>'; <br />}else{ <br /> var spinner = ''; <br />} <br />document.getElementById("spell").innerHTML=spinner; <br />new Ajax.Updater('spell', ’ spell.php', <br />{ method: 'get', success: 'spell', failure: 'errors', parameters: <br />{URL: searchword}}); <br />
  75. 75. Spell.php<br /><?php<br />include ’passwords from outside the webroot';<br />echo "<fieldset><legend>Did you mean ...?</legend><center><h3>";<br />$term = $_GET['URL'];<br />$clean_terms = urldecode($term);<br />$request = 'http://libris.kb.se/bibspell/spell?query='.$term.'&key=XXX';<br />$bibspell = simplexml_load_file($request);<br />$sugcheck = $bibspell->suggestion->term;<br />if($sugcheck){<br />foreach($bibspell->suggestion->term as $suggestion){<br />$suggest .= " $suggestion";<br />$suggest2 .= "$suggestion+";<br />}<br />
  76. 76. Spell.php<br />echo "You searched for <i><font color=red>$clean_terms</font></i><br/><br />LIBR<br />IS suggests you try <a href=http://julia.hj.se/F/?func=find-b&request=$suggest2&<br />find_code=WRD&adjacent=N&x=53&y=1&con_lng=eng>$suggest</a><br /><br />";<br />}else{<br />echo "LIBRIS has no suggestions for you.<br /><br />";<br />}<br />
  77. 77. Spell.php<br />$request = 'http://search.yahooapis.com/WebSearchService/V1/spellingSuggestion?a<br />ppid='.$yahoo_key.'&query='.$term.'';<br />$xml = simplexml_load_file($request);<br />$description = $xml->Result;<br />if (empty($xml->Result)){<br />echo "<p>Yahoo! has no suggestion for you";<br />}else{<br />
  78. 78. Spell.php<br />foreach ($xml->Result as $suggestion) {<br />$suggest = $xml->Result;<br />$suggest2 = http_build_query($suggest);<br />$suggest3 = str_replace('0=','',$suggest2);<br />echo "<p>Yahoo! suggests you try <a href=http://julia.hj.se/F/?func=find-b&reque<br />st=$suggest3&find_code=WRD&adjacent=N&x=53&y=1&con_lng=eng>$suggest</a>";<br />}<br />}<br />echo '</h3><br /><div align="right"><a href="http://developer.yahoo.com/"><br /><img src="http://julia.hj.se/exlibris/aleph/u18_1/alephe/www_f_tst/icon/websrv_1<br />20_1.gif" border="0"><br /></a><br /><a href="http://libris.kb.se"><img src=http://julia.hj.se/exlibris/ale<br />ph/u18_1/alephe/www_f_tst/icon/libris_logotyp.gif border=0></a></div><br /></center></fieldset>';<br />?><br />
  79. 79. <linkrel="alternate" type="application/rdf+xml" title="RDF Representation" href="http://libris.kb.se/data/bib/7156538?format=application%2Frdf%2Bxml" ><br />
  80. 80. Introduktion till API:er, webbtjänster &<br />att integrera LIBRIS tjänster i OPAC<br />[DETTA ÄR SLUTET]<br />Daniel Forsman<br />Chalmers bibliotek<br />Att använda LIBRIS öppna infrastruktur<br />20 maj 2010<br />
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×