``` static String shorten(String url) { ...
# announcements
b
Copy code
static String shorten(String url) {
        String encoded = URLEncoder.encode(url, "UTF-8")

        def result = new JsonSlurper().parse(new URL("<https://api-ssl.bitly.com/v3/shorten?access_token=123&longUrl=$encoded>"))

        return result.data.url.toString()
    }