How to create url_shortner in ruby - ruby-on-rails

I am developing a web application in which I have implemented Facebook and Twitter connectivity.I want to shorten the url when user post to facebook or twitter from my apllication.
For example if url is http://www.MyDomain.com/user/234545 then it should be somwthing like http://M.D/n2b
How can I do that. Please help & also please give me more info about how actually the url shorter works and how to implement it in rails

For starters, you would need to purchase the "M.D" domain, and I don't even think that exists. So your next option would be to use a subdomain of your "MyDomain.com", like "short.MyDomain.com" and stick a Rails app there that could map your shorter URLs. Ironically, the URL would be nearly as long.
It wouldn't surprise me if some of the URL shorteners already out there have some kind of HTTP API. If so, you're probably better off using them.

use bitly or tinyurl or you can create your own method for shorten url if you are using your own method then you cannot change the domain name you have to use some sort of API for doing this.

Related

Shorten URL in Swift iOS with your custom website domain name

I want to shorten a share URL I have in my app when users share a shop. I want a methodology or an API that allows me to shorten the URL to make it look clean but with my website's name.
for instance:
longURL: "https://example.com?x=somevalue&y=someothervalues"
Then when I shorten the URL with an API or method it would produce a small URL similar to this: "https://mywebsite.com/shortenedURLcode"
here is my code:
link = URL(string: "https://mywebsitename.com/share/?shop="+concatenate(getKey!,"&title="+shopName.text!.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!,"&desc="+summary.text!.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)!,"&img="+profileImgURL))
I want to shorten the above link with my website's hostname.
How can I do that?
Here are two options to consider for shortening your URLs:
Bitly API
One option Bitly's API, which will allow you to make requests that return shortened links that fit the above mentioned criteria.
It appears to achieve the result you seek, you must make two requests: one to receive the link with custom domain, and a second to customize the "back half" (See revenant API Documentation in hyperlinked text).
The result of request #2 will contain your fully custom link.
Rebrandly API
The far better option in my opinion is Rebrandly. While I personally don't have any experience using any of Rebrandly's products, I would recommend this option as it has a generous free tier to get you started.
And best of all, the entire shortened link can be formulated in a single request. Will note that what Bitly calls a "back-half" is referred to as the "slashtag" by Rebrandly, but these terms both refer to the exact same thing.
API documentation can be found here.

Zapier to look up Twitter URL mentions

Is it possible to create a Zap that will look-up URL mentions on Twitter?
Been scratching my head with this one, since simply entering URL into Zapier's Twitter Search field doesn't seem to do the trick.
Is it at all possible? Twitter uses its URL shortening service t.co on all links posted. Might this be a reason for me not being able to find any mentions of my URL even when I post one myself? Twitter's native search function finds URL just fine, but not Zapier.
OK, I think I figured it out.
First, use Twitter's special "url" prefix for URL search:
url:amazon - will find URL with the word “amazon” anywhere within it.
Second, most importantly, it looks like the Twitter account I used for testing got ignored after a couple of same URL posts. So be aware of that too.

Dynamic Changing URL (Link Redirector) Service?

I wanted to see if there is a service out there that can dynamically change a URL
Ex. If I wanted someone to go to a landing page like www.handsomeman2015.com/landing2015 and I used a link shortner like bit.ly so I would provide the URL like bit.ly/ag95g and it would direct customers to
But I want to be able to change the URL extension to landing2016, landing2017 etc without changing the web link, is this possible?
Sorry if my question isn't using the correct terminology, as I'm a bit new to this stuff.
Linkredirector is a dynamic URL shortener that lets you change the destination URLs of your links. As long as you register an account you can login and edit your links.
Disclaimer, I work at Linkredirector.
Yourls seems to be an interesting option, if you don't mind installing the service on your own website. Additionally, tiny.cc seems to allow you to change the link through their API.

How do url shorting sites work?

How do URL shorting sites like bit.ly or goo.gl work? Does anyone know what technique or algorithm they use?
Save the URL and generate unique key for the URL and store it in the DB. Use this key to navigate to the URL.
Do you need complex algorithm for this? :-)
If you want to make it complex.
Check for malicious URLs and block them
Have stats based on number of clicks
Have registrations and users have their own small urls
Develop plugins for browsers to generate short urls
etc etc

Enable Query Strings in Code Igniter

I am trying to implement Twitter's OAuth into my Code Igniter web application at which the callback URL is /auth/ so once you have authenticated with Twitter you are taken to /auth/?oauth_token=SOME-TOKEN.
I want to keep the nice clean URL's the framework provides using the /controller/method/ style of URL but I want to enable query strings as well, there will only ever be one name of the data oauth_token so it's ok if it has to be hard coded.
Any ideas?
I have tried tons of the things people are saying to do, but none work :(
PS: I'm using the .htaccess method of URL rewriting.
There are several ways to handle this.
Most People, and Elliot Haughin's Twitter Lib, extend the CI_Input library with a MY_Input library that sets allow_query_strings to true
You will also need to add ? to the allowed characters in config/config.php and set $config['url_protocal'] to PATH_INFO
see here: Enable GET in CodeIgniter
Codeigniter Reactor lets you access $_GET directly or via $this->input->get(). You don't need to use MY_Input or even change your config.php. This method leaves the query string in the URL, however.
I used a hacked index.php to recognise users coming back from Twitter, check for valid and safe values, then re-direct it to to a CodeIgniter friendly URL.
It may not be to everyones taste but I preferred it over allowing query strings throughout the entire application instead of just one particular circumstance.

Resources