うまく取得できなかったんで、結局途中で諦めました。取り合えずメモがてら。
(use srfi-19)
(use srfi-27)
(use rfc.http)
(use rfc.uri)
(use rfc.hmac)
(use rfc.sha)
(use rfc.base64)
(use sxml.ssax)
(use sxml.sxpath) (define *subscrive-key* "hoge")
(define *secret-key* "hogehoge")
(define *associate-tag* "valvallow-22") (define pad0
(lambda (n x)
(format #f "~v,,,'0,@a" n x))) (define date->gmt
(lambda (date)
(let ((g (lambda (ls dl)
(string-join
(map (lambda (f)
(pad0 2 (f date))) ls) dl))))
(string-append (g (list date-year date-month date-day) "-")
(format #f "T~aZ"
(g (list date-hour date-minute date-second) ":")))))) (define param-list
(lambda ()
(list (cons "AWSAccessKeyId" *subscrive-key*)
(cons "keyword" "complete")
(cons "SearchIndex" "Books")
(cons "AssociateTag" "valvallow-22")
(cons "Operation" "ItemSearch")
(cons "ItemPage" "1")
(cons "ResponseGroup" "ItemAttributes")
(cons "Service" "AWSECommerceService")
(cons "Timestamp" (date->gmt (current-date)))
(cons "Version" "2009-07-01")))) (define params-join
(lambda (pl)
(string-join
(sort (map (lambda (pair)
(string-append (car pair)
"="
(uri-encode-string (cdr pair))))
pl)) "&"))) (define auth-req-str
(lambda ()
(string-join (list "GET" "ecs.amazonaws.jp" "/onca/xml"
(params-join (param-list))) "\n"))) (define digest-sha256
(lambda (str key)
(hmac-digest-string str :key key :hasher <sha256>))) (http-get "ecs.amazonaws.jp"
(string-append
"/onca/xml" "?"
(params-join (param-list))
"&Signature="
(uri-encode-string (base64-encode-string
(digest-sha256 (auth-req-str) *secret-key*))))) |
gosh> "403"
(("date" "Thu, 21 Jan 2010 08:23:29 GMT") ("server" "Server") ("vary" "Accept-Encoding,User-Agent") ("cneonction" "close") ("transfer-encoding" "chunked") ("content-type" "text/plain"))
"<?xml version=\"1.0\"?>\n<ItemSearchErrorResponse xmlns=\"http://ecs.amazonaws.com/doc/2009-07-01/\"><Error><Code>SignatureDoesNotMatch</Code><Message>The request signature we calculated does not match the signature you provided. Check your AWS Secret Access Key and signing method. Consult the service documentation for details.</Message></Error><RequestID>49890d99-620b-40b4-9580-6c52d44d2e5d</RequestID></ItemSearchErrorResponse>" |
どっか間違ってるんだろうけど、またそのうち。
参考
0 件のコメント:
コメントを投稿