How to add shortened url to your blog.
In this tutorial,I 'll be making use of bit.ly i.e twitter's default service.STEP BY STEP TUTORIAL.
Login toBlogger&go to Design/Layout » Edit HTML.[Always remember to backup your template.]Check the box next to Expand Widget Template and search for </head> by pressing CTRL+F.On getting that,Copy-Paste the code below directlyabove/before<script type="text/javascript" charset="utf-8" src="http://bit.ly/javascript-api.js?version=latest&login=USERNAME&apiKey=YOURAPIKEY"></script> <script type="text/javascript" charset="utf-8"> 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>
Replace USERNAME with the name you supplied while registering at bit.ly and also replace YOURAPIKEY with the key assigned to your account.STEP 2»
Search for this line of code[CTRL+F]<div class='post-footer-linepost-footer-line-3'>PLACE SCRIPT HERE</div>
Replace “PLACE SCRIPT HERE” in the code above with this»»<b:if cond='data:blog.pageType =="item"'><form id='shorturl'/></b:if>
Now,Preview & Save your template.You should now have a shortened url in all your blog posts. If you encountered any problem trying this,don't hesitate to leave a commen behind.
Tidak ada komentar:
Posting Komentar