Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New Coder
    Join Date
    May 2009
    Posts
    17
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Unshorten a URL via PHP?

    Does anyone know a good way to unshorten a URL using PHP ? What I mean are tinyurls, bit.ly, etc..

    Thanks!

  • #2
    Regular Coder
    Join Date
    Sep 2004
    Posts
    713
    Thanks
    6
    Thanked 2 Times in 2 Posts
    hmmm, maybe can use mysql to store shorturl + long url,

    if you are not running a service, why not use .htaccess
    flying dagger

  • #3
    Regular Coder
    Join Date
    Dec 2009
    Location
    UK
    Posts
    495
    Thanks
    0
    Thanked 58 Times in 58 Posts
    You have three choices:


    1. The first is to do it incrementally (ie aaa aab aac and so on adding to the database every time)
    2. The second randomly with a random string generator, and check to see if that has already been taken in your database, and if not add it. Something like my php random string function would be suitable for this method.
    3. The final method is to fill a database with a preset number of urls that are all unique and then select the ones with no url assigned to it for the url
    My site: JayGilford.com
    Resources:
    PHP Pagination Class | Getting all page links | Handling PHP Errors properly
    If you like a users help, show your appreciation with the rep and thanks buttons :)

  • #4
    Senior Coder
    Join Date
    May 2005
    Posts
    2,137
    Thanks
    96
    Thanked 72 Times in 72 Posts
    I would insert a unique string to the database for it.
    Rowsdower! has accused me of having mental problems, and the administrator allowed it. What a great forum huh?


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •