Skip to content

Instantly share code, notes, and snippets.

@psihy
Created April 11, 2013 09:11
Show Gist options
  • Save psihy/5361907 to your computer and use it in GitHub Desktop.
Save psihy/5361907 to your computer and use it in GitHub Desktop.
;; gauche 0.9.3.3
;; ref. http://developer.hatenastaff.com/entry/2013/04/11/143235
(use rfc.json)
(use rfc.http)
(use rfc.uri)
(define (api-request uri)
(receive (scheme user-info hostname port path query fragment) (uri-parse uri)
(receive (status header body) (http-get hostname path)
(cond ((< (string->number status) 400) (parse-json-string body))
(else (error status))))))
(let ((user (api-request "http://ugomemo.hatena.ne.jp/[email protected]"))
(movies (api-request "http://ugomemo.hatena.ne.jp/11F9E990AA34FFBC@DSi/movies.json")))
(print (assoc-ref user "name") "さんは" (assoc-ref movies "count") "個の作品を投稿しています"))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment