bit.ly: URL shortening web service

release
Slava Pestov 2010-04-12 22:54:30 -07:00
parent 378e0f7f6e
commit b5e99faf4f
4 changed files with 26 additions and 0 deletions

1
extra/bit/ly/authors.txt Normal file
View File

@ -0,0 +1 @@
Slava Pestov

23
extra/bit/ly/ly.factor Normal file
View File

@ -0,0 +1,23 @@
! Copyright (C) 2010 Slava Pestov.
! See http://factorcode.org/license.txt for BSD license.
USING: assocs http.client json.reader kernel namespaces urls ;
IN: bit.ly
SYMBOLS: login api-key ;
<PRIVATE
: make-request ( long-url -- request )
"http://api.bit.ly/v3/shorten" >url
login get "login" set-query-param
api-key get "apiKey" set-query-param
"json" "format" set-query-param
swap "longUrl" set-query-param ;
: parse-response ( response data -- short-url )
nip json> "data" swap at "url" swap at ;
PRIVATE>
: shorten-url ( long-url -- short-url )
make-request http-get parse-response ;

1
extra/bit/ly/summary.txt Normal file
View File

@ -0,0 +1 @@
Wrapper for bit.ly URL shortening web service

1
extra/bit/ly/tags.txt Normal file
View File

@ -0,0 +1 @@
web services