url-shortener

What is the best way in PHP or JS to expand shortened URLs like Bitly, Tinyurl to find the original URL?

大兔子大兔子 提交于 2019-11-30 19:09:24
问题 I am using the Twitter and Facewbook API to pull posts that potentially contain shortened URLs using bit.ly or TinyURL like services. I need to do a real-time expansion to get the original URL then pull content from that URL into my app. 回答1: You can use CURL to expand a short URL. Try this: function traceUrl($url, $hops = 0) { if ($hops == MAX_URL_HOPS) { throw new Exception('TOO_MANY_HOPS'); } $ch = curl_init($url); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_NOBODY, 1);

Developing a URL Shortener

纵然是瞬间 提交于 2019-11-30 12:57:05
问题 I am trying to develop a URL shortener application for practice with Django. I do not understand how can I create unique strings for each long URL to use as a short URL. Something like other popular URL shorteners do. How can I do this? Is it possible to make all short urls of the same length? 回答1: I do not understand how can I create unique strings for each long URL to use as a short URL. Something like other popular URL shorteners do. As sugerman has said, this is simple, you just create a

Could not load file or assembly System.Threading.Tasks, Version=2.5.19.0

别等时光非礼了梦想. 提交于 2019-11-30 12:12:29
I have a WPF (.NET 4) project using google url shortener API, I have installed the client library through nugget https://www.nuget.org/packages/Google.Apis.Urlshortener.v1/1.7.0.25-beta the application works fine in visual studio but once published it throws the exception Could not load file or assembly System.Threading.Tasks, Version=2.5.19.0 this and all other assemblies are present in the installation folder, and it gets publish with application. I have searched internet and people suggest to manually bind the dependency libraries in the app.config, it still does not work as all of my

Using Only Javascript To Shrink URLs Using The Bit.ly API

血红的双手。 提交于 2019-11-30 10:48:58
问题 I'm playing a bit with Javascript these days... I was shrinking some URLs using bit.ly to tweet them, then I started to think on a automated process that could use their API to shrink the URLs I wanted, then I looked up on their documentation, and I saw that they only support PHP(with some Javascript), but there is anyway that I could make this using only Javascript? 回答1: Here is an example how to get a shortened URL with Bitly API and jQuery, no server side code required. function get_short

PHP URL Shortening Algorithm

北战南征 提交于 2019-11-30 05:09:36
Could anyone recommend a preferred algorithm to use for URL shortening? I'm coding using PHP. Initially I thought about writing something that would start at a character such as "a" and iterate through requests, creating records in a database and therefore having to increment the character to b, c, d ... A, B and so on as appropriate. However it dawned on me that this algorithm could be pretty heavy/clumsy and there could be a better way to do it. I read around a bit on Google and some people seem to be doing it with base conversion from the database's ID column. This isn't something I'm too

Using Only Javascript To Shrink URLs Using The Bit.ly API

蓝咒 提交于 2019-11-29 23:13:45
I'm playing a bit with Javascript these days... I was shrinking some URLs using bit.ly to tweet them, then I started to think on a automated process that could use their API to shrink the URLs I wanted, then I looked up on their documentation, and I saw that they only support PHP(with some Javascript), but there is anyway that I could make this using only Javascript? Here is an example how to get a shortened URL with Bitly API and jQuery, no server side code required. function get_short_url(long_url, login, api_key, func) { $.getJSON( "http://api.bitly.com/v3/shorten?callback=?", { "format":

How does a URL Shortener work? [closed]

蓝咒 提交于 2019-11-29 20:05:38
I wonder how a URL Shortener works, like how they extract the text from address bar and map it to correct URL, later redirect it. What programming language do they use? How do they maintain the history of the mapping? How do they ensure the uniqueness of the shortened url? How can a lay man unmap it without visiting the URL? Wiki Is Your Friend Basically, a website with a shorter name is used as a place holder, such as bit.ly. Then, bit.ly generates a key for the user to provide, which is randomly generated to not repeat. With 35 character options and 8 or so values, do the math. That's a lot

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

こ雲淡風輕ζ 提交于 2019-11-29 09:20:02
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": "public", "rewrites": [ { "source": "/url/:item", "destination": "/url/:item" } ] } } index.js file:

Jsoup get redirected URL

a 夏天 提交于 2019-11-29 04:02:51
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? The Response object has a url() method which should give you the final url. So you could do like String url = "http://t.co/i5dE1K4vSs"; Response response = Jsoup

How does a URL Shortener work? [closed]

那年仲夏 提交于 2019-11-28 15:54:10
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 8 years ago . I wonder how a URL Shortener works, like how they extract the text from address bar and map it to correct URL, later redirect it. What programming language do they use? How do they maintain the history of the