已掉线,重新登录

首页 > 绿虎论坛 > 历史版块 > 编程 > PHP > 讨论/求助

标题: file_get_contents有问

作者: @Ta

时间: 2012-06-21

点击: 1555

如何在使用file_get_contents远程获取其它网址页面字符串前声明要调用的是wap网页?因为目标电脑和WAp页面都不相同~

[隐藏样式|查看源码]


『回复列表(3|隐藏机器人聊天)』

1. read.php
(/@Ta/2012-06-21 16:53//)

2. 使用CONTEXT添加HTTP的Accept头来声明自己只支持WAP网页
(/@Ta/2012-06-21 17:26//)

3. <?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);
?>
(/@Ta/2012-06-21 17:34//)

回复需要登录

9月21日 08:02 星期天

本站由hu60wap6驱动

备案号: 京ICP备18041936号-1