Created
October 19, 2010 06:16
-
-
Save StarrWulfe/633705 to your computer and use it in GitHub Desktop.
This script makes a bitly URL for your page and places it in a textbox ready for cut & pasting.
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
<!-- BEGIN Bit.ly Link shortener Callout script **this goes just after </HEAD> in the <BODY> section of the HTML page, template, wherever. This is the actual script that sends the page info to Bit.ly for shortening.** --> | |
<script charset='utf-8' src='http://bit.ly/javascript-api.js?version=latest&login=YOUR_BITLY_LOGIN_HERE&apiKey=YOUR_API_KEY_HERE' type='text/javascript'/> | |
<script charset='utf-8' type='text/javascript'> | |
BitlyClient.addPageLoadEvent(function(){ | |
BitlyCB.myShortenCallback = function(data) { | |
// this is how to get a result of shortening a single url | |
var result; | |
for (var r in data.results) { | |
result = data.results[r]; | |
result['longUrl'] = r; | |
break; | |
} | |
document.getElementById("shorturl").innerHTML = "Share this link: <input type='text' value='" + result['shortUrl'] + "' name='bitlyurl'/>"; | |
} | |
BitlyClient.shorten(document.location, 'BitlyCB.myShortenCallback'); | |
}); | |
</script> | |
<!--END Bitly Callout Script --> | |
<!-- Bit.ly URL BEGIN (place this where you want the shortURL form to show up--> | |
<div> | |
<b:if cond='data:blog.pageType == "item"'><form id='shorturl'/></b:if> | |
</div> | |
<!-- Bit.ly URL END --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
****<script charset='utf-8' src='http://bit.ly/javascript-api.js?version=latest&login=YOUR_BITLY_LOGIN_HERE&apiKey=YOUR_API_KEY_HERE' type='text/javascript'/>
<script charset='utf-8' type='text/javascript'> BitlyClient.addPageLoadEvent(function(){ BitlyCB.myShortenCallback = function(data) { // this is how to get a result of shortening a single url var result; for (var r in data.results) { result = data.results[r]; result['longUrl'] = r; break; } document.getElementById("shorturl").innerHTML = "Share this link: <input type='text' value='" + result['shortUrl'] + "' name='bitlyurl'/>"; } BitlyClient.shorten(document.location, 'BitlyCB.myShortenCallback'); }); </script>