【发布时间】:2014-11-11 12:21:59
【问题描述】:
我正在使用 Indy (Delphi 2009) 在我的免费托管网站上查询 .php 文件。该 .php 读取 URL 提供的参数,从 3rd 方站点下载特定页面并回显源。一切正常,但一些垃圾总是在我下载的有用信息之前。在 Firefox 中,我看不到任何内容。
德尔福部分:
MSource.Lines.Text := IdHTTP1.Get('http://*****.comuv.com/somefile.php?type=upl&id=' + MUsers.Lines.Strings[i]);
.PHP部分:
header('Content-type: text/plain');
...
else if ($_GET['type'] == 'upl')
{
$NextChunkURL = 'http://gdata.youtube.com/feeds/api/users/%UserName%/uploads?start-index=1&max-results=25';
$NextChunkURL = str_replace('%UserName%', $_GET['id'], $NextChunkURL);
$CurChunk = file_get_contents($NextChunkURL);
if ($CurChunk == FALSE)
$CurChunk = 'error downloading [' . $NextChunkURL . ']';
echo $CurChunk;
}
输出示例:
User account closed //GARBAGE IS HERE !!! (always present and looks the same to me)
<!-- Hosting24 Analytics Code -->
<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
<!-- End Of Analytics Code -->
Firefox 开发者工具包代码:
<html><head><link rel="alternate stylesheet" type="text/css" href="resource://gre-resources/plaintext.css" title="Переносить длинные строки"></head>
<body><pre>User account closed
<!-- Hosting24 Analytics Code --><script type="text/javascript"
src="http://stats.hosting24.com/count.php"></script>
<!-- End Of Analytics Code -->
</pre></body></html>
【问题讨论】:
标签: php delphi download indy byte-order-mark