url-shortener

YouTube-like GUID

喜夏-厌秋 提交于 2019-11-28 04:29:23
Is it possible to generate short GUID like in YouTube (N7Et6c9nL9w)? How can it be done? I want to use it in web app. You could use Base64: string base64Guid = Convert.ToBase64String(Guid.NewGuid().ToByteArray()); That generates a string like E1HKfn68Pkms5zsZsvKONw== . Since a GUID is always 128 bits, you can omit the == that you know will always be present at the end and that will give you a 22 character string. This isn't as short as YouTube though. eglasius 9 chars is not a Guid. Given that, you could use the hexadecimal representation of an int, which gives you a 8 char string. Update 1:

Cloud Functions for Firebase: 'Error: could not handle the request'

被刻印的时光 ゝ 提交于 2019-11-28 03:00:19
问题 I feel like pulling my hair out; this is either super simple and i'm having brain freeze or it is not that simple. What I want I am trying to unshorten a shortened URL using firebase, when a user goes to: myapp.firebaseappurl.com/url/SHORTENEDLINK SO wont let me add a shortened URL I would like the output to be: { "url": "https://stackoverflow.com/questions/45420989/sphinx-search-how-to-use-an-empty-before-match-and-after-match" } What I have tried firebase.json file: { "hosting": { "public":

Jsoup get redirected URL

人走茶凉 提交于 2019-11-27 16:34:00
问题 I'm trying to fetch the actual(redirected) url from the one provided by a url shortener. Let's take twitter url shortener for example. I'm able to get the response object also parsed it to get the document. Response response = Jsoup.connect("http://t.co/i5dE1K4vSs") .followRedirects(true) //to follow redirects .execute(); Now, considering a single redirect, where to get the final url from? Any method or strategy to achieve this? 回答1: The Response object has a url() method which should give

Find where a t.co link goes to

心已入冬 提交于 2019-11-27 12:22:30
Given a t.co link, how can I find see where the link resolves? For example, if I have t.co/foo, I want a function or process that returns domain.com/bar. I would stay away from external APIs over which you have no control. That will simply introduce a dependency into your application that is a potential point of failure, and could cost you money to use. CURL can do this quite nicely. Here's how I did it in PHP: function unshorten_url($url) { $ch = curl_init($url); curl_setopt_array($ch, array( CURLOPT_FOLLOWLOCATION => TRUE, // the magic sauce CURLOPT_RETURNTRANSFER => TRUE, CURLOPT_SSL

jQuery on the fly URL shortener

家住魔仙堡 提交于 2019-11-27 11:57:43
I'm looking for an on the fly URL shortener much like how tweetdeck works. I have found many jQuery and general javascript plugins that take a url and run it through a shortening service such as bit.ly when a button is pressed. However, I have not been able to find one that does it on the fly. My first question is does this already exist someplace? Secondly, if it doesn't, then what would be the best way to recognize a URL that needs to be shortened inside a textbox? My thoughts: On onKeyUp of that text area run through the text looking for http If found grab the whole URL (how do I determine

How do short URLs services work?

跟風遠走 提交于 2019-11-27 10:01:53
How do services like TinyURL or Metamark work? Do they simply associate the tiny URL key with a [virtual?] web page which merely provide an "HTTP redirect" to the original URL? or is there more "magic" to it ? [original wording] I often use URL shortening services like TinyURL, Metamark, and others, but every time I do, I wonder how these services work. Do they create a new file that will redirect to another page or do they use subdomains? Abel No, they don't use files. When you click on a link like that, an HTTP request is send to their server with the full URL, like http://bit.ly/duSk8wK

YouTube-like GUID

六眼飞鱼酱① 提交于 2019-11-27 05:16:30
问题 Is it possible to generate short GUID like in YouTube (N7Et6c9nL9w)? How can it be done? I want to use it in web app. 回答1: You could use Base64: string base64Guid = Convert.ToBase64String(Guid.NewGuid().ToByteArray()); That generates a string like E1HKfn68Pkms5zsZsvKONw== . Since a GUID is always 128 bits, you can omit the == that you know will always be present at the end and that will give you a 22 character string. This isn't as short as YouTube though. 回答2: 9 chars is not a Guid. Given

How can I unshorten a URL?

大城市里の小女人 提交于 2019-11-26 17:42:22
问题 I want to be able to take a shortened or non-shortened URL and return its un-shortened form. How can I make a python program to do this? Additional Clarification: Case 1: shortened --> unshortened Case 2: unshortened --> unshortened e.g. bit.ly/silly in the input array should be google.com in the output array e.g. google.com in the input array should be google.com in the output array 回答1: Send an HTTP HEAD request to the URL and look at the response code. If the code is 30x, look at the

Find where a t.co link goes to

不羁岁月 提交于 2019-11-26 15:59:07
问题 Given a t.co link, how can I find see where the link resolves? For example, if I have t.co/foo, I want a function or process that returns domain.com/bar. 回答1: I would stay away from external APIs over which you have no control. That will simply introduce a dependency into your application that is a potential point of failure, and could cost you money to use. CURL can do this quite nicely. Here's how I did it in PHP: function unshorten_url($url) { $ch = curl_init($url); curl_setopt_array($ch,

How do short URLs services work?

风流意气都作罢 提交于 2019-11-26 14:59:21
问题 How do services like TinyURL or Metamark work? Do they simply associate the tiny URL key with a [virtual?] web page which merely provide an "HTTP redirect" to the original URL? or is there more "magic" to it ? [original wording] I often use URL shortening services like TinyURL, Metamark, and others, but every time I do, I wonder how these services work. Do they create a new file that will redirect to another page or do they use subdomains? 回答1: No, they don't use files. When you click on a