Home > Backend Development > PHP Tutorial > 当get_headers 服务器返回403 forbidden 如何获得 短网址 真实地址

当get_headers 服务器返回403 forbidden 如何获得 短网址 真实地址

WBOY
Release: 2016-06-13 13:32:54
Original
966 people have browsed it

当get_headers 服务器返回403 forbidden 怎么获得 短网址 真实地址?

当get_headers 服务器返回403 forbidden 怎么获得 短网址 真实地址?

------解决方案--------------------

PHP code
<?php $header = "Host: t.cn\r\nConnection: keep-alive\r\nUser-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.168 Safari/535.19\r\nAccept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\nAccept-Encoding: gzip,deflate,sdch\r\nAccept-Language: zh-CN,zh;q=0.8,en;q=0.6,en-US;q=0.4,sq;q=0.2\r\nAccept-Charset: UTF-8,*;q=0.5\r\n";
$request = array('method' => 'GET',
                'header' => $header );
stream_context_get_default( array('http'=>$request) );
// 我以新浪微薄为例
$response = get_headers("http://t.cn/SfwrDk", 1);
var_dump($response['Location']); <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template