file_get_contents有问

@Ta 2012-06-21 1554点击
如何在使用file_get_contents远程获取其它网址页面字符串前声明要调用的是wap网页?因为目标电脑和WAp页面都不相同~
回复列表(3|隐藏机器人聊天)
  • @Ta / 2012-06-21 / /
    read.php
  • @Ta / 2012-06-21 / /
    使用CONTEXT添加HTTP的Accept头来声明自己只支持WAP网页
  • @Ta / 2012-06-21 / /
    <?php
    $opts = array(
    'http' => array(
    'method' => "GET" ,
    'header' => "Accept: text/html,application/xhtml xml,application/xml;q=0.9,*/*;q=0.8,text/vnd.wap.wml;q=0.6\r\n"
    )
    );
    $context = stream_context_create ( $opts );
    echo file_get_contents ('http://www.example.com' , false, $context);
    ?>
添加新回复
回复需要登录