jaw jaw - 23 days ago 5x
PHP Question

Api for url Expander in php

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.


On your Question I think You want to expand tiny Urls. Its is also Possible using Curl And Php .

function ger_origenal_url($url)
    $ch = curl_init($url);
    curl_setopt($ch,CURLOPT_HEADER,true); // Get header information
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION,false);
    $header = curl_exec($ch);

    $fields = explode("\r\n", preg_replace('/\x0D\x0A[\x09\x20]+/', ' ', $header)); // Parse information

        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;


I think this is helpful for you.