gpt4 book ai didi

php - 在 php 中创建的数据源未验证

转载 作者:行者123 更新时间:2023-11-30 00:25:23 25 4
gpt4 key购买 nike

我必须按照代码将数据上传到第三方。但是,当我在验证器中测试它时,出现以下错误:

Undefined root elements:items and text/xml media type is not specific enough.

我不知道我需要改变什么。

这是代码:

header('Content-Type: text/xml');
echo '<?xml version="1.0" encoding="UTF-8"?>
<items>';
mysql_select_db($database_dconn, $dconn);
$query_feed = "SELECT * FROM dat_table WHERE time BETWEEN (NOW() - INTERVAL 7 DAY) AND NOW()";
$feed = mysql_query($query_feed, $dconn) or die(mysql_error());
while ($row_feed = mysql_fetch_assoc($feed)){


echo'<item>
<name>'.$row_feed['Name'].'</name>
<email>'.$row_feed['email'].'</email>
<date>'.$row_feed['Date'].'</date>
<description>'.$row_feed['Make'].' '.$row_feed['Model'].' '.$row_feed['Type'].'</description>
<logon>'.$row_feed['Logon'].'</logon>
<category>'.$row_feed['Type'].'/'.$row_feed['Make'].'</category>
<product_search_code>'.$row_feed['Product_search_code'].'</product_search_code>
<order_ref>'.$row_feed['Invoice'].'</order_ref>
<product_link>'.$row_feed['Product_link'].'</product_link>
<customer_ref>'.$row_feed['Invoice'].'</customer_ref>
<amount>'.$row_feed['Price'].'</amount>
<currency>GBP</currency>
</item>';
}
echo '</items>
';

这是验证器中输出的 RSS:

<?xml version="1.0" encoding="UTF-8"?>
<items><item>
<name>Name of customer</name>
<email>customer@gmail.com</email>
<date>03/04/2014</date>
<description>Roland FP80BK Piano</description>
<logon>www.pianoandkeyboardshoponline.co.uk</logon>
<category>Piano/Roland</category>
<product_search_code>264</product_search_code>
<order_ref>8336</order_ref>
<product_link>http://www.pianoandkeyboardshop.co.uk/Roland-FP80-Digital-Piano-in-Satin-Black/264</product_link>
<customer_ref>8336</customer_ref>
<amount>1500.00</amount>
<currency>GBP</currency>
</item><item>
next item etc
---
--
</item><items>

非常感谢任何帮助。

最佳答案

text/xml 内容类型适用于通用 XML 文档。对于 Feed,请尝试使用

header('Content-Type: application/rss+xml');

但无论如何,为了创建有效的 RSS,您必须使用正确的 RSS 标签(例如 this )。您似乎使用了很多自定义标签,所以我不知道您到底需要做什么。最简单的解决方案是为自定义标签使用命名空间,例如:

header('Content-Type: application/rss+xml');
echo '<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:mytags="http://mytags.something.net">
<channel>
<title>My RSS Title</title>
<description>This is the description for my RSS feed</description>
<link>http://www.someexamplerssdomain.com/main.html</link>
<mytags:items>';
mysql_select_db($database_dconn, $dconn);
$query_feed = "SELECT * FROM dat_table WHERE time BETWEEN (NOW() - INTERVAL 7 DAY) AND NOW()";
$feed = mysql_query($query_feed, $dconn) or die(mysql_error());
while ($row_feed = mysql_fetch_assoc($feed)){
echo '<mytags:item>
<mytags:name>'.$row_feed['Name'].'</mytags:name>
<mytags:email>'.$row_feed['email'].'</mytags:email>
<mytags:date>'.$row_feed['Date'].'</mytags:date>
<mytags:description>'.$row_feed['Make'].' '.$row_feed['Model'].' '.$row_feed['Type'].'</mytags:description>
<mytags:logon>'.$row_feed['Logon'].'</mytags:logon>
<mytags:category>'.$row_feed['Type'].'/'.$row_feed['Make'].'</mytags:category>
<mytags:product_search_code>'.$row_feed['Product_search_code'].'</mytags:product_search_code>
<mytags:order_ref>'.$row_feed['Invoice'].'</mytags:order_ref>
<mytags:product_link>'.$row_feed['Product_link'].'</mytags:product_link>
<mytags:customer_ref>'.$row_feed['Invoice'].'</mytags:customer_ref>
<mytags:amount>'.$row_feed['Price'].'</mytags:amount>
<mytags:currency>GBP</mytags:currency>
</mytags:item>';
}
echo '</mytags:items>
</channel>
</rss>';

关于php - 在 php 中创建的数据源未验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22933271/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com