Skip to content

Instantly share code, notes, and snippets.

@onozaty
Created January 20, 2013 14:34
Show Gist options
  • Save onozaty/4579122 to your computer and use it in GitHub Desktop.
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/
// 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