Advertisement
ak47suk1

ak47suk1

Jul 21st, 2010
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.58 KB | None | 0 0
  1. /* I'm starting to learn php.
  2. * Below is modified sample code from u.nu
  3. *
  4. * Example:
  5. *
  6. * Input: kaibathelegacy.blogspot.com
  7. *
  8. * Output: Shortened URL = http://u.nu/3gmd
  9. *
  10. */
  11.  
  12. <?php
  13. echo "Please enter your URL \n";
  14. $original_url = trim(fgets(STDIN));
  15. $request = 'http://u.nu/unu-api-simple?url='.urlencode($original_url);
  16. $response = file_get_contents($request);
  17. if (substr($request, 0, 4) == 'http')
  18. {
  19.    echo "Shortened URL = $response";
  20. }
  21. else
  22. {
  23.    list ($error_code, $error_message) = explode('|', $response);
  24.    echo "Error = $error_message ($error_code)";
  25. }
  26. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement