SHOUTcast XML 使用 php 获取
我有shoutcast管理员,我需要从中读取xml,它看起来像这样
http://SHOUTCAST-IP:PORT /admin.cgi
我需要登录并从 http://SHOUTCAST-IP:PORT/admin.cgi?mode=viewxml 并用 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);
}
但它不起作用,它说 未经授权。
。我该如何修复它?
I have shoutcast administrator and i need to read xml from that it looks like this
http://SHOUTCAST-IP:PORT/admin.cgi
And i need to login and get the XML Data from http://SHOUTCAST-IP:PORT/admin.cgi?mode=viewxml and do it with php, i have made this script
$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);
}
But it doesn't work, it says Unauthorised
. How can i fix it ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(2)
您确定可以使用标准 $_GET 变量在那里提供
用户名
和密码
吗?看起来很糟糕的做法!?我会使用 cURL 来实现这一点,它既快速又简单!
Are you sure you can use standard $_GET variables to provide
username
andpassword
there? Seems quite bad practice!?I would use cURL to achieve this, it's quick and easy!
这个怎么样?
What about this?