【发布时间】:2019-12-10 15:39:58
【问题描述】:
我正在尝试构建一个 HTML/PHP 应用程序,您可以在其中将 RSS URL 输入到表单字段中,然后通过访问 rssfeed.php 页面在浏览器中检索 RSS 提要。目前,我收到一个错误file_get_contents() expects parameter 1 to be a valid path, array given in C:\xampp\htdocs\week14\rssfeed.php on line 2
这是我的 index.html 代码:
<html>
<body>
<form action="rssfeed.php" method="post">
Please enter the RSS feed URL: <input type="content" name="name"><br>
<input type="submit">
</form>
</body>
</html>
这里是 rssfeed.php 代码:
<?php
$content = file_get_contents($_POST);
?>
甚至不知道该谷歌什么了,我是从头开始构建代码的新手。
所以这就是显示来自 espn 的提要,但我需要集成它,以便当我在表单中键入 URL 时,它会将那个 URL 放置到此代码 sn-p 中的 url 当前所在的位置:
$feed_url = "http://rssfeeds.usatoday.com/UsatodaycomGolf-TopStories";
$content = file_get_contents($feed_url);
$x = new SimpleXmlElement($content);
echo '<ul>';
foreach($x->channel->item as $entry) {
echo '<li>';
echo '<a href="'.$entry->link.'" title="'.$entry->title.'" target="_blank">' . $entry->title . '</a>'; // output link & title
echo $entry->description; // return post content
echo '</li>';
}
echo "</ul>";
【问题讨论】:
-
type="content"html5doctor.com/html5-forms-input-types - 可能是问题的根源。 -
file_get_contents($_POST);- 您需要指定$_POST中的哪个字段用作文件名。 -
类型应该是 URL,因为我传递了一个完整的 URL,但是我希望它 POST 或嵌入自身,以便它像我转到实际的 RSS Url 时一样显示,但我只能这样做一个实时服务器,所以这可能是问题的一半,因为本地主机不在互联网上。
-
我需要告诉php文件它正在使用什么文件?
标签: php html forms rss rss-reader