Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* I'm starting to learn php.
- * Below is modified sample code from u.nu
- *
- * Example:
- *
- * Input: kaibathelegacy.blogspot.com
- *
- * Output: Shortened URL = http://u.nu/3gmd
- *
- */
- <?php
- echo "Please enter your URL \n";
- $original_url = trim(fgets(STDIN));
- $request = 'http://u.nu/unu-api-simple?url='.urlencode($original_url);
- $response = file_get_contents($request);
- if (substr($request, 0, 4) == 'http')
- {
- echo "Shortened URL = $response";
- }
- else
- {
- list ($error_code, $error_message) = explode('|', $response);
- echo "Error = $error_message ($error_code)";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement