Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Tcl) SCIS SearchSee more SCiS Schools Catalogue ExamplesDemonstrates the SCIS (Schools Catalogue Information Service) search API call.
load ./chilkat.dll # This example assumes the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. set http [new_CkHttp] # Implements the following CURL command: # curl -i -X GET --url 'https://api.scisdata.com/catalogue/api/search?query=titleSearch%3Adogs%20AND%20publicationYear%3A2015&from=0&size=20&sort=author&order=asc' -H 'Authorization: Basic ****' # Use the following online tool to generate HTTP code from a CURL command # Convert a cURL Command to HTTP Source Code # This causes the "Authorization: Basic ****" to be added to each request. CkHttp_put_Login $http "myLogin" CkHttp_put_Password $http "myPassword" CkHttp_put_BasicAuth $http 1 set sbQuery [new_CkStringBuilder] CkStringBuilder_Append $sbQuery "titleSearch:dogs AND publicationYear:2015" set sbUrl [new_CkStringBuilder] CkStringBuilder_Append $sbUrl "https://api.scisdata.com/catalogue/api/search?query=" # If non-usascii chars are included in the search, we don't know if utf-8 or windows-1252 is desired by the server. You'll need to find out.. CkStringBuilder_Append $sbUrl [CkStringBuilder_getEncoded $sbQuery "url" "utf-8"] CkStringBuilder_Append $sbUrl "&from=0&size=20&sort=author&order=asc" set sbResponseBody [new_CkStringBuilder] set success [CkHttp_QuickGetSb $http [CkStringBuilder_getAsString $sbUrl] $sbResponseBody] if {$success == 0} then { puts [CkHttp_lastErrorText $http] delete_CkHttp $http delete_CkStringBuilder $sbQuery delete_CkStringBuilder $sbUrl delete_CkStringBuilder $sbResponseBody exit } set jResp [new_CkJsonObject] CkJsonObject_LoadSb $jResp $sbResponseBody CkJsonObject_put_EmitCompact $jResp 0 puts "Response Body:" puts [CkJsonObject_emit $jResp] set respStatusCode [CkHttp_get_LastStatus $http] puts "Response Status Code = $respStatusCode" if {$respStatusCode >= 400} then { puts "Response Header:" puts [CkHttp_lastHeader $http] puts "Failed." delete_CkHttp $http delete_CkStringBuilder $sbQuery delete_CkStringBuilder $sbUrl delete_CkStringBuilder $sbResponseBody delete_CkJsonObject $jResp exit } # Sample JSON response: # (Sample code for parsing the JSON response is shown below) # { # "data": { # "hits": { # "hits": [ # { # "_index": "scisdata2", # "_type": "bibdatatype", # "_source": { # "isbn": [ # "9781517638160" # ], # "languageTermCode": [ # "eng" # ], # "mainAuthor": { # "namePersonalPrimary": [ # "Abbott, Eleanor Hallowell." # ] # }, # "title": { # "titlePrimary": [ # "Peace on Earth, good-will to dogs" # ], # "noteStmOfResponsibility": [ # "by Eleanor Hallowell Abbott." # ] # }, # "scisType": [ # "Book" # ], # "dateIssuedMarc": 2015, # "languageTermValue": [ # "English" # ], # "contributor": {}, # "isbn13": "9781517638160", # "imageFileName": "9781517638160.jpg", # "publicationDetails": "United States, Create Space Independent Publishing Platform, 2015", # "isbn10": "151763816X", # "id": "1867852" # }, # "_id": "1867852", # "sort": [ # "abbott, eleanor hallowell." # ], # "_score": null # }, # { # "_index": "scisdata2", # "_type": "bibdatatype", # "_source": { # "isbn": [ # "9781780747910" # ], # "languageTermCode": [ # "eng" # ], # "mainAuthor": { # "namePersonalPrimary": [ # "Adams, Richard." # ] # }, # "title": { # "titlePrimary": [ # "The plague dogs" # ], # "noteStmOfResponsibility": [ # "Richard Adams." # ] # }, # "scisType": [ # "Book" # ], # "dateIssuedMarc": 2015, # "languageTermValue": [ # "English" # ], # "contributor": {}, # "isbn13": "9781780747910", # "imageFileName": "9781780747910.jpg", # "publicationDetails": "New York, Rock the Boat, 2015", # "isbn10": "1780747918", # "id": "1749228" # }, # "_id": "1749228", # "sort": [ # "adams, richard." # ], # "_score": null # }, # ... # ], # "total": 84, # "max_score": null # }, # "took": 585, # "timed_out": false # }, # "subscriptionStatus": {} # } # Sample code for parsing the JSON response... # Use the following online tool to generate parsing code from sample JSON: # Generate Parsing Code from JSON set dataHitsTotal [CkJsonObject_IntOf $jResp "data.hits.total"] set dataHitsMax_score [CkJsonObject_stringOf $jResp "data.hits.max_score"] set dataTook [CkJsonObject_IntOf $jResp "data.took"] set dataTimed_out [CkJsonObject_BoolOf $jResp "data.timed_out"] set i 0 set count_i [CkJsonObject_SizeOfArray $jResp "data.hits.hits"] while {$i < $count_i} { CkJsonObject_put_I $jResp $i set v_index [CkJsonObject_stringOf $jResp "data.hits.hits[i]._index"] set v_type [CkJsonObject_stringOf $jResp "data.hits.hits[i]._type"] set v_sourceDateIssuedMarc [CkJsonObject_IntOf $jResp "data.hits.hits[i]._source.dateIssuedMarc"] set v_sourceIsbn13 [CkJsonObject_stringOf $jResp "data.hits.hits[i]._source.isbn13"] set v_sourceImageFileName [CkJsonObject_stringOf $jResp "data.hits.hits[i]._source.imageFileName"] set v_sourcePublicationDetails [CkJsonObject_stringOf $jResp "data.hits.hits[i]._source.publicationDetails"] set v_sourceIsbn10 [CkJsonObject_stringOf $jResp "data.hits.hits[i]._source.isbn10"] set v_sourceId [CkJsonObject_stringOf $jResp "data.hits.hits[i]._source.id"] set v_id [CkJsonObject_stringOf $jResp "data.hits.hits[i]._id"] set v_score [CkJsonObject_stringOf $jResp "data.hits.hits[i]._score"] set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "data.hits.hits[i]._source.isbn"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set strVal [CkJsonObject_stringOf $jResp "data.hits.hits[i]._source.isbn[j]"] set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "data.hits.hits[i]._source.languageTermCode"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set strVal [CkJsonObject_stringOf $jResp "data.hits.hits[i]._source.languageTermCode[j]"] set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "data.hits.hits[i]._source.mainAuthor.namePersonalPrimary"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set strVal [CkJsonObject_stringOf $jResp "data.hits.hits[i]._source.mainAuthor.namePersonalPrimary[j]"] set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "data.hits.hits[i]._source.title.titlePrimary"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set strVal [CkJsonObject_stringOf $jResp "data.hits.hits[i]._source.title.titlePrimary[j]"] set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "data.hits.hits[i]._source.title.noteStmOfResponsibility"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set strVal [CkJsonObject_stringOf $jResp "data.hits.hits[i]._source.title.noteStmOfResponsibility[j]"] set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "data.hits.hits[i]._source.scisType"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set strVal [CkJsonObject_stringOf $jResp "data.hits.hits[i]._source.scisType[j]"] set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "data.hits.hits[i]._source.languageTermValue"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set strVal [CkJsonObject_stringOf $jResp "data.hits.hits[i]._source.languageTermValue[j]"] set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "data.hits.hits[i].sort"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set strVal [CkJsonObject_stringOf $jResp "data.hits.hits[i].sort[j]"] set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "data.hits.hits[i]._source.contributor.namePersonalOther"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set strVal [CkJsonObject_stringOf $jResp "data.hits.hits[i]._source.contributor.namePersonalOther[j]"] set j [expr $j + 1] } set j 0 set count_j [CkJsonObject_SizeOfArray $jResp "data.hits.hits[i]._source.contributor.nameCorporateOther"] while {$j < $count_j} { CkJsonObject_put_J $jResp $j set strVal [CkJsonObject_stringOf $jResp "data.hits.hits[i]._source.contributor.nameCorporateOther[j]"] set j [expr $j + 1] } set i [expr $i + 1] } delete_CkHttp $http delete_CkStringBuilder $sbQuery delete_CkStringBuilder $sbUrl delete_CkStringBuilder $sbResponseBody delete_CkJsonObject $jResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.