我从表中提取数据以生成itunes Feed。
类别标记的格式为:
<itunes:category text="Games & Hobbies">
</itunes:category>
我从表格中的字段中获取此值,即类别。
这:
<itunes:category text=".$data['category']."</itunes:category>
输出:
<itunes:category text=Games & Hobbies</itunes:category>
</itunes:category>
而不是:
<itunes:category text="Games & Hobbies">
</itunes:category>
它忽略了该类别的语音标记。我已经尝试了各种括号组合,但仍然遇到语法错误。
以下完整脚本:
<?php
include("authenticate.php");
$user = $_SESSION['UserName'];
$initialdata = $result = mysql_query("SELECT * FROM ccregisterfeed WHERE username = '$user'");
$initdata = mysql_fetch_assoc($initialdata);
$result = mysql_query("SELECT * FROM ccshowcontent JOIN ccaudio ON ccshowcontent.id = ccaudio.id WHERE ccshowcontent.username = '$user' ORDER BY ccshowcontent.id DESC")
or die(mysql_error());
while($row = mysql_fetch_assoc($result)){
$items[] = $row;
}
function createXML($items,$data){
$xml = "<?xml version='1.0' encoding='UTF-8'?>
<rss xmlns:itunes="http://www.itunes.com/DTDs/Podcast-1.0.dtd" version="2.0">
<channel>
<title>".$data['feedtitle']."</title>
<link>".$data['websitelink']."</link>
<language>en-GB</language>
<copyright>".$data['copyright']."</copyright>
<itunes:subtitle>".$data['subtitle']."</itunes:subtitle>
<itunes:author>".$data['author']."</itunes:author>
<description>".$data['feeddescription']."</description>
<itunes:image href=".$data['imagelink']."/>
<itunes:category text=".$data['category']."</itunes:category>
<title>".$data['feedtitle']."</title>
<link>".$data['websitelink']."</link>
<category text=>".$data['category']."</category>
<pubDate>".date("D, d M Y H:i:s O", strtotime($data['pubdate']))."</pubDate>
<language>en-us</language>
<image>
<title>".$data['feedtitle']."</title>
<link>".$data['websitelink']."</link>
<url>".$data['imagelink']."</url>
<description>".$data['imagetitle']."</description>
</image>";
$audiodir = "http://thetradingcardgenerator.com/MP3/";
foreach($items as $key => $item){
$path = $audiodir.$item['path'];
$pdate = strtotime($item['pubdate']);
$date = date("D, d M Y H:i:s O", $pdate);
$xml .="
<item>
<title>".$item['title']."</title>
<description>".$item['description']."></description>
<guid>".$path."</guid>
<pubDate>".$date."</pubDate>
<itunes:duration>".$data['imagelink']."</itunes:duration>
</item>";
}
$xml .="
</channel>
</rss>";
return $xml;
}
$rss = createXML($items,$initdata);
//echo "feed updated!";
$filename = "itunes" . strtolower(str_ireplace(" ", "", $initdata['feedtitle']) . ".xml");
file_put_contents($filename,$rss);
header("Location: ccupload.php?message=".urlencode("Content Added <br/> Feed Updated"));
// var_dump ($filename);
?>
答案 0 :(得分:1)
看起来你只是缺少一些引号和一个结束尖括号:
"...<itunes:category text=\"".$data['category']."\"></itunes:category>..."
^^ ^^^
如果修复后仍然出现语法错误,请使用确切的错误消息更新您的问题。