URL Shortener Services

Discussion in 'PHP and MySQL' started by vareside, Jul 22, 2009.

  1. vareside New Member

    Hey folks,

    I'm trying to create a form for my website where users are able to short their URL's using one out of many different services. The form shall be like that: First a drop down menu to choose a service, then a text field to enter the long URL and then a "GO!" or "CUT IT!" button. I have already the API code for U.NU, so I just need the form coding but to let PHP handle that form. But how?

    Here the PHP API code from U.NU:
    PHP:
    $original_url 'http://www.vareside.com/';
    $request 'http://u.nu/unu-api-simple?url=' urlencode($original_url);
    $response file_get_contents($request);
    if (
    substr($request04) == 'http')
    {
       echo 
    "Shortened URL = $response";
    }
    else
    {
       list (
    $error_code$error_message) = explode('|'$response);
       echo 
    "Error = $error_message ($error_code)";
    }
    I hope someone can help me as fast as possible.
    Thanks to all of you!
  2. bmcoll3278 New Member

    I am not sure with a api I use a php file to write a folder create a index.html in the folder and the index file is a redirect with the correct url. then the link is printed out by the file as well. that way my long urls are short and friendly. if you have a short url you could offer the service yourself this way.