I create a short url using tinyurl Api. now i am finding Api that expand these tinyurls i tried to find but only get websites that expand the url not api. I want api that dynamically expand the url in my website.
Asked
Active
Viewed 808 times
-1
-
1Is there a programming question coming, or are you just giving us your wish list? (SO is a Q&A for specific programming questions where you can ask detailed questions about a problem, while showing us what you, yourself, have tried to solve that said problem). – M. Eriksson Sep 28 '16 at 05:39
2 Answers
1
On your Question I think You want to expand tiny Urls. Its is also Possible using Curl And Php .
<?php
function ger_origenal_url($url)
{
$ch = curl_init($url);
curl_setopt($ch,CURLOPT_HEADER,true); // Get header information
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION,false);
$header = curl_exec($ch);
$fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $header)); // Parse information
for($i=0;$i<count($fields);$i++)
{
if(strpos($fields[$i],'Location') !== false)
{
$url = str_replace("Location: ","",$fields[$i]);
}
}
return $url;
}
$url = 'your tiny url';
$original_url = ger_origenal_url($url); // Calling function with short url
echo $original_url;
exit;
?>
I think this is helpful for you.

vikash
- 465
- 1
- 5
- 22
-
-
In some cases Location is writen "location" (case of Mercado Pago's short URL). Using stripos and str_ireplace solve this problem) – Peter Jul 18 '20 at 19:08
0
What exactly you want to achieve , As i understand you want to add something to your tinyurl with some api help,You can append these url simply by your code , or else if you want to add some data in these urls , You can take a look at branch.io it is good for adding many data in a short url .Like deeplink

Mukesh Swami
- 415
- 2
- 11