いよいよ商品一覧表示部分に着手する。
んでDWSのデータはSpecTextUrl、CopyPcTextUrl、HtmlPcTextUrlなどの要素に各商品の追記情報のURLが記載されていて、内容を表示するためにはさらにそこへ取得しに行かなければいけない。面倒なので省略するつもりだったが、これをチャレンジする機会と捉えてjavascriptで読み込んで表示しようと思った。しかしよく考えると、それではhtmlソースにwebサービスのアクセスキーを記載する(漏らす)事になってしまう。一旦自分のサイトへアクセスさせてからリダイレクトで本来のURLへ飛ばせばいいんだろうか。よくわからん。しかも大した情報が書かれているわけでもなし。それどころか未だに<CENTER>タグが大文字で使われている始末だ。無視するか。
ページめくりにはPEARのPagerを使おうと思う。
問題点が発覚。カテゴリのデータはAPIでカテゴリIDとカテゴリ名を取得できる。しかしショップはIDとショップ名を取得するAPIがないため、ショップID縛りでショップ内商品検索結果を表示する際にショップ名を表示できない。
↓
ショップ名を取得するためだけに、商品一覧APIでショップID指定・表示数1で問い合わせるか。
category.xml
object(SimpleXMLElement)#2 (1) { ["Category"]=> array(11) { [0]=> object(SimpleXMLElement)#3 (4) { ["CategoryCode"]=> string(1) "1" ["CategoryDepth"]=> string(1) "1" ["CategoryName"]=> string(18) "コンピュータ" ["SubCategorys"]=> object(SimpleXMLElement)#14 (1) {
カテゴリ検索API
object(SimpleXMLElement)#1 (1) { ["Category"]=> array(11) { [0]=> object(SimpleXMLElement)#4590 (3) { ["CategoryId"]=> string(1) "1" ["CategoryName"]=> string(18) "コンピュータ" ["Count"]=> string(4) "2292" }
商品検索API
object(SimpleXMLElement)#4440 (1) { ["Responce"]=> object(SimpleXMLElement)#4667 (5) { ["Hid"]=> string(5) "38097" ["TotalItems"]=> string(3) "166" ["TotalPages"]=> string(1) "9" ["Details"]=> array(20) { [0]=> object(SimpleXMLElement)#4665 (39) { ["ItemID"]=> string(7) "2751278" ["ShopID"]=> string(3) "250" ["ProductName"]=> string(200) "【3月末まで特別割引】一点物12cm大オルゴナイトピラミッド『コスミックレムリアン』(4種のアゼツライト天然石入)【送料無料】【ヘブン&アース】" ["Price"]=> string(5) "30000" ["DefaultPrice"]=> string(5) "60000" ["ImageUrlSmall"]=> string(58) "http://image.store-mix.com/products/images/samnail/2751278" ["ImageUrlMedium"]=> string(59) "http://image.store-mix.com/products/images/samnail2/2751278" ["ImageUrlLarge"]=> string(59) "http://image.store-mix.com/products/images/samnail3/2751278" ["LinkURL"]=> string(78) "http://www.store-mix.com/ko-bai/product.php?pid=2751278&hid=*****&aftype=dws30" ["Manufacture"]=> string(23) "Heaven & Earth LLC" ["Availability"]=> string(6) "3-4日" ["Stock"]=> string(1) "1" ["StockInfinity"]=> string(1) "0" ["ItemDetail"]=> object(SimpleXMLElement)#4680 (0) { } ["SalesStatus"]=> string(9) "販売中" ["CategoryID"]=> string(4) "1854" ["ShopName"]=> string(32) "天然石アクセサリーFROMS" ["TaxFree"]=> string(1) "1" ["DeliveryFree"]=> string(1) "1" ["DeliveryFreeCondition"]=> string(52) "商品の合計金額が5000円以上で送料無料" ["DeliveryCostType"]=> string(1) "1" ["DeliveryCostMin"]=> string(3) "500" ["DeliveryCostMax"]=> string(3) "500" ["Card"]=> string(1) "0" ["Point"]=> string(1) "1" ["AfFee"]=> string(1) "3" ["LimitedAfFee"]=> string(1) "0" ["LimitedAfStart"]=> string(1) "0" ["LimitedAfEnd"]=> string(1) "0" ["TimeSales"]=> string(5) "25800" ["TimeSalesStart"]=> string(10) "2015020400" ["TimeSalesEnd"]=> string(10) "2015033124" ["SpecTextUrl"]=> string(123) "http://webservice.d-064.com/3.x/GetElement.php?accesskey=*******************************&product_id=2751278&text_type=spec" ["CopyPcTextUrl"]=> string(126) "http://webservice.d-064.com/3.x/GetElement.php?accesskey=*******************************&product_id=2751278&text_type=copy_pc" ["CopyMobileTextUrl"]=> string(130) "http://webservice.d-064.com/3.x/GetElement.php?accesskey=********************************&product_id=2751278&text_type=copy_mobile" ["HtmlPcTextUrl"]=> string(126) "http://webservice.d-064.com/3.x/GetElement.php?accesskey=********************************&product_id=2751278&text_type=html_pc" ["HtmlMobileTextUrl"]=> string(130) "http://webservice.d-064.com/3.x/GetElement.php?accesskey=********************************&product_id=2751278&text_type=html_mobile" ["CommentPcTextUrl"]=> string(129) "http://webservice.d-064.com/3.x/GetElement.php?accesskey=********************************&product_id=2751278&text_type=comment_pc" ["MovieTextUrl"]=> string(124) "http://webservice.d-064.com/3.x/GetElement.php?accesskey=********************************&product_id=2751278&text_type=movie" }
商品検索APIへアクセスキー無しでアクセス
object(SimpleXMLElement)#4440 (1) { ["error"]=> object(SimpleXMLElement)#4667 (2) { ["code"]=> string(1) "1" ["message"]=> string(45) "販売店が見つかりませんでした。" } }
商品検索API 深夜バッチ中?空データが返る。AM4:45 しかしcategory.xmlとカテゴリAPIはちゃんとデータを取得できている。
<ProductInfo></ProductInfo>
object(SimpleXMLElement)#4440 (1) { ["Responce"]=> object(SimpleXMLElement)#4667 (5) { ["Hid"]=> string(5) "38097" ["TotalItems"]=> string(1) "1" ["TotalPages"]=> string(1) "1" ["Details"]=> object(SimpleXMLElement)#4665 (0) { } ["CategoryTree"]=> object(SimpleXMLElement)#4664 (0) { } } }
F5押しっぱなしにしたら3分間のアクセス禁止の刑に。空データが欲しかったの。許して!
この間もcategory.xmlは取得可能。静的ファイルだからだろうか。
アクセスキーの必要な商品検索APIだけでなく、アクセスキーの不要なカテゴリAPIも遮断されたので、アクセスキーではなくIPアドレスで弾かれた模様。
Service Temporarily Unavailable
The bwshare module will refuse your requests for the next 174 seconds.
You have downloaded data too rapidly.
AM5:00 バッチ終了か。データが取得できるようになった。
- 電脳卸…ログイン画面で詳しい情報が公開されています(PHPサンプルスクリプトあり)