【发布时间】:2012-02-07 05:50:17
【问题描述】:
我有直播管理员,我需要从中读取 xml,它看起来像这样
http://SHOUTCAST-IP:PORT/admin.cgi
我需要登录并从http://SHOUTCAST-IP:PORT/admin.cgi?mode=viewxml 获取 XML 数据并使用 php 完成,我已经制作了这个脚本
$fp = fsockopen($server, $port, $errno, $errstr, 30);
fputs($fp, "GET /admin.cgi?pass=".$password."&mode=viewxml HTTP/1.0\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)\r\n\r\n"); //
while (!feof($fp)) {
$content = fgets($fp);
}
但它不起作用,它显示Unauthorised。我该如何解决?
【问题讨论】:
-
你的标题有点乱。你为什么不改用 cURL 呢?不要重新发明轮子……不需要直接为此使用套接字。