mysqlurltinyurl

Store urls in mysql using tinyurl or similar


I want to store a large number of unique, indexable urls in mysql. They will be written by the user and will have a really broad acceptance, so almost anything goes there.

But I don't like the already answered SO question nor it's predecessor. Actually I think there might be a 'better' way for doing so, but I don't completely see the implications of this, so that's why I ask this question.

What are the advantages/disadvantages of using tinyurl.com's API for this purpose? In this link we can see an article about how to do this. It's just this code (could be even shorter but I prefer it in a function):

function createTinyUrl($strURL)
  {
  return file_get_contents("http://tinyurl.com/api-create.php?url=".$strURL);
  }

Then I would have to compare only the example in tinyurl.com/example to check the uniqueness of the link. From the wikipedia article we can read:

If the URL has already been requested, TinyURL will return the existing alias rather than create a duplicate entry.

Disadvantages (basically same ones as using any centralized system):

Any other disadvantage that you can see using this method? The main reason for using it is not to have duplicated entries and to make them indexable.


Solution

  • As the user eggyal suggested, a hash based index of the full URI is really similar to using the Tinyurl API, only I don't need to send data anywhere. I will use that then.

    NOTE: this answer is here only to add closure to the question