TinyUrl class
Possible Methods
__construct
Default constructor
Return
void
Example
<?php
// require the class
require_once 'tinyurl.php';
// create instance
$tinyUrl = new TinyUrl();
?>
setTimeOut
Set the timeout
After this time the request will stop. You should handle any errors triggered by this.
Parameters
- seconds int
- The timeout in seconds
Return
void
setUserAgent
Set the user-agent for you application
It will be appended to ours, the result will look like: "PHP TinyUrl/<version> <your-user-agent>"
Parameters
- userAgent string
- Your user-agent, it should look like <app-name>/<app-version>
Return
void
create
Create a TinyUrl
Parameters
- url string
- The orginal url that should be shortened
Return
string
Example
<?php
// require the class
require_once 'tinyurl.php';
// create instance
$tinyUrl = new TinyUrl();
// create a TinyUrl
echo $tinyUrl->create('http://blog.verkoyen.eu/blog/p/detail/php-tinyurl-class-create-and-reverse');
?>
Output
http://tinyurl.com/klaofb
reverse
Reverse a TinyUrl into a real url
Parameters
- url string
- The short tinyUrl that should be reversed
Return
mixed If something fails it will return false, otherwise the orginal url will be returned as a string
Example
<?php
// require the class
require_once 'tinyurl.php';
// create instance
$tinyUrl = new TinyUrl();
// reverse an existing TinyUrl
echo $tinyUrl->reverse('http://tinyurl.com/aplvg');
?>
Output
http://crsolutions.be