URL Shorteners Within Other Services

URL Shorteners Within Other Services

06.Oct.2021

    Have you ever seen a link and felt intimidated by its size? Well there is an answer to that problem! URL shorteners, such as TinyURL , Bit.ly, and Goo.gl (to name a few) can take your long links and turn them into tiny links that are easier to share with friends or post on websites like reddit or digg. The cool part about these shorteners is that they can be used on many different websites by simply pasting in the URL you want to shorten and clicking the generate link button (usually protected by a captcha because spammers love using them).

 

After generating your link, it will take you to the webpage where others will view your shortened link, but how do these providers get around email or website protection policies? Well, they need the ability to shorten URLs within their own pages. If we look at bit.ly's API documentation , we can see that such a feature exists: "bitly_login_link() : Returns an HTML login link for Bit.ly so users don't have to remember their long API keys." This means that a website can post or email a bit.ly link and a user won't have to enter their API key, nor leave the webpage they are viewing!

 

As far as I know, there is no way around this restriction, so it must be done every time a URL needs to be shortened within your own service. If you want proof of how easy it is to open up shortening capabilities for your entire website (or part), take my word for it or look at Wikipedia's edit history . It appears that Wikipedia used TinyURL (which has an api available here ) via JavaScript before switching over to the MediaWiki API with redirects enabled which looks like this:

 

< form name = "redir" action = "http://tinyurl.com/api-create.php" method = "post" > < input type = "hidden" name = "url" value = "" />< br /> Shorten this page:< br /> < br/> < input type = "submit" >< /form >

 

And there you have it! A way to shorten any url within your own service without an API and without having to leave the webpage! Now if only we could make those shortened links stop redirecting us all over the web…

 

 

 

I went ahead and tested this out on Wikipedia (see the edit history for proof). It seems like it only works on the main page. I was unable to get it to work when I then clicked on the shortened link that had been sent in an email. Perhaps there's a way to make shortlinks inside of emails but I'm not exactly sure how that would work without the API, and maybe every good spammer already knows about this method anyway since they read sites like this one daily. =) Let me know what you think in the comments section below! Thanks for reading!

(original article was written by me)

Please note, I do not work for Wikipedia. This post is provided solely for educational purposes. Please excuse any errors in my code examples, these are meant to be used as reference only! Thank you! (oh and please don't delete this article!) Reply Delete

So instead of giving someone an API key why not just sign them up, generate the link and send it to them? Because if I'm not mistaken there's no automated way to unsubscribe somebody - which means your service can be exploited. Reply Delete

Yes that's true but some services like bitly have a free plan that doesn't even require you to enter an email address so it would be more effort than its worth unless you are trying to make a point about how easy it is to create your own shortener. I think this method would be more useful as a educational tool as opposed to something that might need wide spread use anyway. Reply Delete

I tried the following code:

however it submits the url as the default title instead of the address or what ever I'm supposed to input or copy into my blog :O Reply Delete

 

I tried this out on your site and was able to post any link, great article! Reply Delete

The problem with using simple shorteners like tinyurl is that usually if you access a page through them, you first have to click another page first. For instance, I recently got sent an email where someone shortened a URL for me. The link led back to their website first before sending me onto our destination website. This should be prevented at all costs. Reply Delete

This info is not new but it's still really useful and definitely worth a link in anyone's blog or article who is writing about URL shorteners. Reply Delete

I'm so glad I found this post! It seems like everyone has been using TinyURL lately, but I found that it was very easy to setup my own (and much more secure) URL shortener: Reply Delete

Thank you thank you thank you!!! That worked perfectly for me and I didn't even know how to do it without the api before! Reply Delete

No problems here either, thanks very much for taking the time to write up such a clear tutorial on this subject! Reply Delete

 

We are social