PHP bunu nasıl yapabilirim? örneğin
bit.ly/f00b4r ==> http://www.google.com/search?q=cute+kittens
Java, çözelti şudur:
You should issue a HEAD request to the url using a HttpWebRequest instance. In the returned HttpWebResponse, check the ResponseUri.
Just make sure the AllowAutoRedirect is set to true on the HttpWebRequest instance (it is true by default). (Thx, casperOne)
Ve kodu
private static string GetRealUrl(string url)
{
WebRequest request = WebRequest.Create(url);
request.Method = WebRequestMethods.Http.Head;
WebResponse response = request.GetResponse();
return response.ResponseUri.ToString();
}
(Thx, Fredrik Mork)
Ama PHP bunu yapmak istiyorum. NASIL? :)