Because Weibo has a word limit, if you send a website, it will be automatically changed to a short website. My previous articles introduced how to convert a web site into a short Web site. Here we will, in turn, restore the short Web site to the actual web site. Refer to the following program and use PHP for implementation:
<? Php $ url = "http://163.fm/1QLJ8U"; echo unshorten ($ url); function unshorten ($ url) {$ url = trim ($ url); $ headers = get_headers ($ url ); $ location = $ url; $ short = false; foreach ($ headers as $ head) {if ($ head = "HTTP/1.1 302 Found") $ short = true; if ($ short & startwith ($ head, "Location:") {$ location = substr ($ head, 10) ;}} return $ location ;} function startwith ($ Haystack, $ Needle) {return strpos ($ Haystack, $ Needle) = 0;}?>
The program running result is as follows:
Http://www.bkjia.com/