I've written a program to auto shorten the link and it use api of my website but i have to when i click on an shortened link ( like : goo.gle/~~~ ) this program dont use my service and redirect to link with out Reshorten link! as you know the shortner link service changing the urls now i need to a program that if find a content like ( goo.gle ) in my value then Regardless of Reshorten service and use the api
elseif ($url == "http://goo.gle/")
{
header("HTTP/1.1 301 Moved Permanently");
header("Location: $url");
}
else
{
$orls = "http://losa.net/api.php?key=dc4c0b38b62b44f69467c33eaf7ce08b&uid=128&adtype=int&url=".$url."";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$orls);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
$content=curl_exec ($ch);
curl_close ($ch);
header("HTTP/1.1 301 Moved Permanently");
header("Location: $content");
}
Not sure exactly what you are asking, but I will answer to what I understood.
You can determine if the URL is using a shortening service by using a regex and seeing if the first part of the url is under a certain amount of characters, not sure how long the longest one is, but something like 5 or less characters.
If it is then try to get PHP to capture the header and find out where it is redirecting two or use an API such as LongUrl.
Reshorten.
Or if you are saying you want to disregard your API if the URL is already shortened you can do:
Same as step one of previous, use a regex to see if the first part is less than 5 characters.
Try to expand
If you can expand redirect.