Last active
December 16, 2015 22:49
-
-
Save aeg/5510314 to your computer and use it in GitHub Desktop.
短縮URLの展開。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://blog.livedoor.jp/dankogai/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
println expandURL("http://j.mp/dankogai") | |
public String expandURL(String urlStr) { | |
HttpURLClient http = new HttpURLClient(followRedirects:false) | |
def params = [ url:urlStr, | |
headers:['User-Agent':'Mozilla/5.0'] ] | |
def resp = http.request( params ) | |
return resp.headers.'Location' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment