Created
January 20, 2013 14:34
-
-
Save onozaty/4579122 to your computer and use it in GitHub Desktop.
Convert to short url from RSS link url.
This is IRCBot Console Script.(by Rhino)
http://www.enjoyxstudy.com/ircbotconsole/
This file contains 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
// set api key | |
// https://developers.google.com/url-shortener/v1/getting_started#auth | |
var api = 'https://www.googleapis.com/urlshortener/v1/url?key={your API Key}'; | |
var paramater = JSON.stringify({'longUrl': _link}); | |
var request = new Packages.org.apache.http.client.methods.HttpPost(api); | |
request.setHeader('Content-Type', 'application/json'); | |
request.setEntity( | |
new Packages.org.apache.http.entity.StringEntity(paramater, 'UTF-8')); | |
var response = new Packages.org.apache.http.impl.client.DefaultHttpClient().execute(request); | |
var responseText = Packages.org.apache.http.util.EntityUtils.toString(response.getEntity()); | |
var result = JSON.parse(responseText); | |
_title + " " + result.id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment