I have create the process on script:
1. Bit.ly Short URLs Using PHP API,
2. TinyURL Short URLs Using PHP,
3. Is.Gd Short URLs Using PHP
4. U.Nu Short URLs Using PHP, 5. Won Short URLs Using PHP
Bit.ly process:
[php]
<?php
/* returns the shortened url */
function get_bitly_short_url($url,$login,$appkey,$format='txt') {
$connectURL = 'http://api.bit.ly/v3/shorten?login='.$login.'&apiKey='.$appkey.'&uri='.urlencode($url).'&format='.$format;
return curl_get_result($connectURL);
}
/* returns expanded url */
function get_bitly_long_url($url,$login,$appkey,$format='txt') {
$connectURL = 'http://api.bit.ly/v3/expand?login='.$login.'&apiKey='.$appkey.'&shortUrl='.urlencode($url).'&format='.$format;
return curl_get_result($connectURL);
}
/* returns a result form url */
function curl_get_result($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
/* get the short url */
$short_url = get_bitly_short_url('<your url as like http://blog.insafeta.com/>','<your user name>','<your api key>');
echo $short_url;
/* get the long url from the short one */
$long_url = get_bitly_long_url($short_url,'<your user name>','<your api key>');
echo $long_url;
?>
[/php]
TinyURL process:
[php]
<?php
//Gets the data from a URL
function get_tiny_url($url) {
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,'http://tinyurl.com/api-create.php?url='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
//Test it out!
$new_url = get_tiny_url('http://blog.insafeta.com');
//Returns http://tinyurl.com/c9te6vc
echo $new_url;
?>
[/php]
Is.Gd process:
[php]
<?php
//gets the data from a URL
function get_isgd_url($url)
{
//get content
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,'http://is.gd/api.php?longurl='.$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$content = curl_exec($ch);
curl_close($ch);
//return the data
return $content;
}
//uaging process
$new_url = get_isgd_url('http://blog.insafeta.com/');
echo $new_url;
?>
[/php]
U.Nu process:
[php]
<?
function get_unu_url($url)
{
$url = 'http://u.nu/unu-api-simple?url='.urlencode($url);
$ch = curl_init();
$timeout = 5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$url = curl_exec($ch);
curl_close($ch);
return trim($url);
}
$short_url = get_unu_url('http://blog.insafeta.com');
echo $short_url;
?>
[/php]
To create your won web as like Bit.ly, TinyURL, Is.Gd, U.Nu webs please visit the article and for more information contact with me.
I am now not positive where you are getting your information, however great topic. I needs to spend some time studying much more or understanding more. Thanks for excellent info I used to be looking for this info for my mission.
ReplyDeleteThis video post is really impressive, the sound feature and the picture feature of this video post is really remarkable.
ReplyDeleteI just want to mention I am just beginner to blogging and absolutely savored you're web page. Most likely I’m going to bookmark your blog post . You certainly have good article content. Many thanks for sharing your web-site.
ReplyDelete