| パラメータ | 意味 | 内容 |
|---|---|---|
| 1つ目のディレクトリ名 | 検索文字列 | 検索キーワード(URLエンコードします) |
| 2つ目のディレクトリ名 | おともだちID | お試し用IDは「aOENZ00002」です |
| hardware | 動作ハードウェア | 2桁数字 |
| os | 動作OS | 2桁数字 |
| viewer | 動作ビューワーソフト | 2桁数字 |
| shop | 電子書籍販売サイトID | 4桁大文字英字 |
| payment | 決済方法ID | 2桁大文字英字 |
| genre1 | 第一分類 | 3桁数字 |
| genre2 | 第二分類 | 3桁数字 |
| genre3 | 第三分類 | 3桁数字 |
| isbn13 | ISBNコード(13桁版) | 紙書籍が存在した場合、そのISBNコード(ハイフンなし)。※旧10桁版は出ません。 |
| description50 | キャッチコピー文表示フラグ | on(default)/off |
| publ | 出版社指定 | 4桁大文字英字 |
| sort | 表示順 | id(作品ID順、デフォルト)/rank7(7日間ランキング順)/rank90(90日間ランキング順) |
| max | 1ページの表示最大件数 | (デフォルト:10件) |
| page | 表示ページ | (デフォルト:1ページ) |
| mode | XML出力モード | full/compact/genrelist(デフォルトはfull、最小限表示はcompact、分類IDマスタ出力はgenrelistを使用) |
| xslt | XSLT指定 | 無指定または「xml」でxml表示/ファイル(URL)指定でXSLT変換 |
| パラメータ | 意味 | 詳細 |
|---|---|---|
| %E6%9C%AC/ | URLエンコードされた検索キーワード=「本」 | 本 |
| aOENZ00002/ | おともだちID:aOENZ00002 | |
| hardware=70 | 動作ハードウェア ID:70 | PC |
| &genre1=600 | 第一分類 ID:300 | 雑学・趣味 |
| &genre2=100 | 第二分類 ID:400 | 健康・生活 |
| &sort=rank7 | 表示順:rank7 | 7日間ランキング順 |
| &publ=FAAF | 出版社指定:FAAF | 小学館のみ |
|
HTMLに変換するXSLTファイルを用意すると、RESTの結果をHTMLとして利用できます。
検索条件とXSLTファイルを指定したRESTのURLを、ブラウザのブックマークなどに登録できます。
サンプルの表示(別ウィンドウ)
http://hon.jp/rest/2.1/
%A5%A2%A5%D5%A5%EA%A5%AB/
aOENZ00002/
xslt=http://hon.jp/
csv/rest_xslsample/
sample_20.xsl
この例では、「英語」というキーワードによるREST検索を行い、その結果をXSLTファイル「sample_20.xsl」を用いてHTMLに変換しています。
XSLTを右に示します。
XSLTファイル「sample_20.xsl」は、RESTによるXMLの情報のほとんどをHTMLに変換しています。 必要な情報のみを抽出することで、目的に合わせたHTMLに変換できます。 |
XSLTサンプル(HTML表示)
<?xml version="1.0" encoding="UTF-8" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:template match="/"> <html lang="ja"> <head> <title>検索結果:<xsl:value-of select="ProductInfo/totalResults" /></title> <style TYPE="text/css"> </style> </head> <body> <xsl:apply-templates select="ProductInfo/request" /> <hr /> ヒット数: <xsl:value-of select="ProductInfo/totalResults" /> (ページ数: <xsl:value-of select="ProductInfo/totalPages" /> ) <hr /> <xsl:apply-templates select="ProductInfo/results" /> </body> </html> </xsl:template> <xsl:template match="request"> 以下のリクエストがありました <div id="request"> <xsl:apply-templates select="args" /> </div> </xsl:template> <xsl:template match="request/args"> <table border="1"> <tr> <th>項目</th> <th>値</th> </tr> <xsl:apply-templates select="arg" /> </table> </xsl:template> <xsl:template match="arg"> <tr> <td> <xsl:value-of select="./@name"/> </td> <td> <xsl:value-of select="./@value"/> </td> </tr> </xsl:template> <xsl:template match="results"> <div> <table border="1" width="100%"> <tr> <td colspan="2"><h3><xsl:value-of select="title"/></h3></td> </tr> <tr> <th>作品ID</th> <td><xsl:value-of select="title/@id"/></td> </tr> <tr> <th>情報</th> <td><xsl:value-of select="description50"/></td> </tr> <tr> <th>著者</th> <td><xsl:value-of select="creator"/></td> </tr> <tr> <th>出版社</th> <td><xsl:value-of select="publisher"/>(<xsl:value-of select="publisher/@id"/>)</td> </tr> <tr> <th>分類</th> <td><xsl:apply-templates select="genreInfo" /></td> </tr> <tr> <th>電子書籍</th> <td><xsl:apply-templates select="details" /></td> </tr> </table> </div> <hr /> </xsl:template> <xsl:template match="genreInfo"> <div> <xsl:value-of select="genre1" />(<xsl:value-of select="genre1/@id"/>)/ <xsl:value-of select="genre2" />(<xsl:value-of select="genre2/@id"/>)/ <xsl:value-of select="genre3" />(<xsl:value-of select="genre3/@id"/>) </div> </xsl:template> <xsl:template match="details"> <div> <a> <xsl:attribute name="href"> <xsl:value-of select="url"/> </xsl:attribute> <xsl:attribute name="target">_blank</xsl:attribute> <span style="font-size:9px;"><xsl:value-of select="honjp_id" /></span>: <xsl:value-of select="hardware" />(<xsl:value-of select="hardware/@id"/>): <xsl:value-of select="os" />(<xsl:value-of select="os/@id"/>): <xsl:value-of select="viewer" />(<xsl:value-of select="viewer/@id"/>): <xsl:value-of select="shop" />(<xsl:value-of select="shop/@id"/>): <xsl:value-of select="payment" />(<xsl:value-of select="payment/@id"/>): <xsl:value-of select="sale_date" /> <xsl:value-of select="account" /> </a> </div> </xsl:template> </xsl:stylesheet> |
|
RSS形式に変換するXSLTファイルを用意すると、RESTの結果をRSSとして利用できます。
検索条件とXSLTファイルを指定したRESTのURLを、BLOGやRSSリーダに設定できます。
サンプルの表示(別ウィンドウ)
http://hon.jp/rest/2.1/
%A5%A2%A5%D5%A5%EA%A5%AB/
aOENZ00002/
xslt=http://hon.jp/
csv/rest_xslsample/
sample_20_rss2.xsl
この例では、「英語」というキーワードによるREST検索を行い、その結果をXSLTファイル「sample_20_rss2.xsl」を用いてRSS2形式のXMLに変換しています。
XSLTを右に示します。
一つの書籍は、電子書店・プラットフォームなどが異なる複数の電子書籍データを持ちます。
サンプルのXSLTは、電子書籍に直接リンクするのではなく、書籍のページにリンクさせています。 もちろん、電子書籍に直接リンクさせるRSSも設定できます。 |
XSLTサンプル(RSSに変換)
<?xml version="1.0" encoding="UTF-8" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="xml" indent="yes" encoding="UTF-8"/> <xsl:template match="/"> <xsl:variable name="keyword"> <xsl:for-each select="ProductInfo/request/args/arg"> <xsl:if test="@name[(.='keyword')]"> <xsl:value-of select="./@value"/> </xsl:if> </xsl:for-each> </xsl:variable> <rss version="2.0"> <channel> <title>HON.JP - <xsl:value-of select="" /></title> <link>http://hon.jp/</link> <description>HON.JP</description> <lastBuildDate><xsl:value-of select="ProductInfo/modified_rfc822"/></lastBuildDate> <docs>http://backend.userland.com/rss/</docs> <generator></generator> <category></category> <managingEditor></managingEditor> <webMaster></webMaster> <language>ja</language> <xsl:for-each select="ProductInfo/results"> <item> <title><xsl:value-of select="title"/></title> <link><xsl:value-of select="concat(url,'&kw=',)"/></link> <description><xsl:value-of select="description50"/></description> <pubDate><xsl:value-of select="issue_date_rfc822"/></pubDate> <guid><xsl:value-of select="concat(url,'&kw=',)"/></guid> </item> </xsl:for-each> </channel> </rss> </xsl:template> </xsl:stylesheet> |
|
インナーフレームを用いて、そこにHTMLに変換させたhon.jp - REST結果を表示させます。
あなたのwebページ上で、 「事前に設定しておいた検索条件の結果の表示」 「電子書籍の検索」 が可能になります。
下に示す例では、
ページを開いた時には、キーワード「英語」の検索結果がインナーフレームに表示されています。 フォームにキーワードを入れて検索ボタンをクリックすると、そのキーワードの検索結果がインナーフレームに表示されます。
XSLTを右に示します。
このページの「検索フォーム」「インラインフレーム」「javaScript」も右に示します。
javaScriptのRESTのパラメータ部分を書き換えることで、キーワード検索以外の検索も可能になります。 |
XSLTサンプル(インナーフレームを用いて、webページに表示)
<?xml version="1.0" encoding="UTF-8" ?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" > <xsl:output method="html" indent="yes" encoding="UTF-8"/> <xsl:template match="/"> <xsl:variable name="keyword"> <xsl:for-each select="ProductInfo/request/args/arg"> <xsl:if test="@name[(.='keyword')]"> <xsl:value-of select="./@value"/> </xsl:if> </xsl:for-each> </xsl:variable> <html lang="ja"> <head> <title>hon.jp検索結果:<xsl:value-of select="" /></title> <style TYPE="text/css"> body{font-size:12px;} .headBox{background-color:#edc9c9; } </style> </head> <body> <div class="headBox" align="center"> <a> <xsl:attribute name="href"> http://hon.jp/ </xsl:attribute> <xsl:attribute name="target">_parent</xsl:attribute> hon.jp </a> </div> <xsl:for-each select="ProductInfo/results"> <div class="contents"> <a> <xsl:attribute name="href"> <xsl:value-of select="concat(url,'&kw=',)"/> </xsl:attribute> <xsl:attribute name="target">_blank</xsl:attribute> <xsl:value-of select="title"/> </a> </div> </xsl:for-each> </body> </html> </xsl:template> </xsl:stylesheet> インナーフレームHTML
<script type="text/javascript"> function iframeSearch() { var escKw = encodeURI( document.form_iframe.kw.value ); var url = 'http://hon.jp/rest/2.1/' + escKw + '/aOENZ00002/xslt=http://hon.jp/csv/rest_xslsample/sample_ebk20.xsl'; elmIframe.location.href = url; } </script> <form name="form_iframe"> <input type="text" name="kw" /> <input type="button" name="if_search" value="検索" onClick="iframeSearch();" /> </form> <iframe src="http://hon.jp/rest/2.1/ %B1%D1%B8%EC/ aOENZ00002/ xslt=http://hon.jp/csv/rest_xslsample/ sample_ebk20.xsl" name="elmIframe" width="160" height="180" marginwidth="2" marginheight="2" scrolling="auto" frameborder="yes" align="left"> </iframe> |
| パラメータ | 意味 | 詳細 |
|---|---|---|
| aOENZ00002 | おともだちID:aOENZ00002 | サンプルIDです |
| mode | 誘導監視モードは「jumplist」 | 直近3作品の誘導ログを出力 |
の表示をいただくと、開発チームの励みとなると同時にうちの社長もけっこう喜んだりしますので、大変ありがたいです。もし画像表示ができない場合は、代わりに「データ提供元:hon.jp Webサービス」とか「hon.jpのWebサービスのデータです。」等々のテキスト注意書きレベルでも全然OKです。| | 電子書籍検索サイト「hon.jp」 | 本サイトのご利用について | お問い合わせ | WebサービスAPI | 会社概要 | |