我用这个来生成RSS发布到我的Facebook墙上......但是在过去24小时内它停止了工作。我认为我使用的推送服务对RSS验证变得严格。这没有验证......我也无法得到它。任何人都可以提出修改以使其工作吗?我知道这可能看起来非常混乱! :OS
提前致谢。
<?php do { ?>
<item>
<title><![CDATA[<?php echo htmlentities(strip_tags(addslashes($row_getDresses['listing_title']))); ?><?php if($_GET['type'] == "reduced-dresses"){?> (REDUCED BY <?php echo $row_getDresses['symbol'];?><?php echo $row_getDresses['reduced_price'];?> <?php echo $row_getDresses['dress_currency'];?>)<?php } else {?> (<?php echo $row_getDresses['symbol'];?><?php echo $row_getDresses['price'];?> <?php echo $row_getDresses['dress_currency'];?>)<?php }?>]]></title>
<link><![CDATA[http://www.asite.com/dress/<?php echo $row_getDresses['listing_tidy_url'];?>-<?php echo $row_getDresses['dress_id'];?>.html]]></link>
<description><![CDATA[<?php echo substr(strip_tags(addslashes(trim($row_getDresses['dress_desc'])),'ENT_QUOTES'),0,100);?>]]>...</description>
<?php if (isset($row_getDresses['main_image']) && file_exists("../listing-images/".$row_getDresses['main_image']."")) { ?>
<enclosure url="http://www.asite.com/listing-images/<?php echo $row_getDresses['main_image'];?>" length="<?php echo filesize("../listing-images/".$row_getDresses['main_image']."");?>" type="image/jpeg">
<?php }?>
<?php if ($_GET['type'] == "reduced-dresses"){?>
<pubDate><?php echo $row_getDresses['date_updated'];?> GMT</pubDate>
<?php } else { ?>
<pubDate><?php echo $row_getDresses['date_added'];?> GMT</pubDate>
<?php }?>
<category><?php echo htmlentities($pageTitle);?></category>
</item>
<?php } while ($row_getDresses = mysql_fetch_assoc($getDresses)); ?>
答案 0 :(得分:2)
你没有关闭enclosure-tag,添加</enclosure>
或只在标签的末尾添加/
,如<enclosure ... />
<强>更新强>
可读性是可靠的,这是我的编码风格代码的例子:
<?php
do
{
/* preper data */
$category = htmlentities($pageTitle);
$link = "http://www.asite.com/dress/{$row_getDresses['listing_tidy_url']}-{$row_getDresses['dress_id']}.html";
$description = substr(strip_tags(addslashes(trim($row_getDresses['dress_desc'])),'ENT_QUOTES'),0,100);
$title = htmlentities(strip_tags(addslashes($row_getDresses['listing_title'])));
/* Reduced price? */
if($_GET['type'] == "reduced-dresses")
{
$title .= " (REDUCED BY {$row_getDresses['symbol']}{$row_getDresses['reduced_price']} {$row_getDresses['dress_currency']})";
$date = $row_getDresses['date_updated'];
}
else
{
$titlt .= " ({$row_getDresses['symbol']}{$row_getDresses['price']} {$row_getDresses['dress_currency']})";
$date = $row_getDresses['date_added'];
}
/* image exists? */
if(isset($row_getDresses['main_image']) AND file_exists("../listing-images/".$row_getDresses['main_image'].""))
{
$image = "http://www.asite.com/listing-images/{$row_getDresses['main_image']}";
$image_size = filesize("../listing-images/".$row_getDresses['main_image']."");
}
else
{
$image = FALSE;
}
/* write RSS */
echo "<item>";
echo "<title><![CDATA[{$title}]]></title>";
echo "<link><![CDATA[{$link}]]></link>";
echo "<description><![CDATA[{$description}]]>...</description>";
if($image)
{
echo "<enclosure url='{$image}' length='{$image_size}' type='image/jpeg' />";
}
echo "<pubDate>{$date} GMT</pubDate>";
echo "<category>{$category}</category>";
echo "</item>";
} while ($row_getDresses = mysql_fetch_assoc($getDresses));
?>
答案 1 :(得分:0)
我试图让它更具可读性,是的,封闭空间没有关闭:
<?php
$new_rss = '';
do {
$new_rss .= '<item>';
$new_rss .= '<title><![CDATA[' . htmlentities( strip_tags( addslashes( $row_getDresses[ 'listing_title' ] ) ) );
if( $_GET[ 'type' ] == 'reduced-dresses') {
$new_rss .= '(REDUCED BY ' . $row_getDresses[ 'symbol' ] . $row_getDresses[ 'reduced_price' ] . $row_getDresses[ 'dress_currency' ] . ')';
} else {
$new_rss .= '(' . $row_getDresses[ 'symbol' ] . $row_getDresses[ 'price' ] . $row_getDresses[ 'dress_currency' ] . ')';
}
$new_rss .= ']]></title>';
$new_rss .= '<link><![CDATA[http://www.asite.com/dress/' . $row_getDresses[ 'listing_tidy_url' ] . '-' . $row_getDresses[ 'dress_id' ] . '.html]]></link>';
$new_rss .= '<description><![CDATA[' . substr( strip_tags( addslashes( trim( $row_getDresses[ 'dress_desc' ] ) ), 'ENT_QUOTES' ), 0, 100 ) . ']]>...</description>';
if ( isset( $row_getDresses[ 'main_image' ] ) && file_exists( '../listing-images/' . $row_getDresses[ 'main_image' ] ) ) {
$new_rss .= '<enclosure url="http://www.asite.com/listing-images/' . $row_getDresses[ 'main_image' ] . '" length="' . filesize( '../listing-images/' . $row_getDresses[ 'main_image' ] ) . '" type="image/jpeg" />';
}
if ( $_GET[ 'type' ] == 'reduced-dresses' ) {
$new_rss .= '<pubDate>' . $row_getDresses[ 'date_updated' ] . ' GMT</pubDate>';
} else {
$new_rss .= '<pubDate>' . $row_getDresses[ 'date_added' ] . ' GMT</pubDate>';
}
$new_rss .= '<category>' . htmlentities($pageTitle) . '</category>';
$new_rss .= '</item>';
} while ( $row_getDresses = mysql_fetch_assoc( $getDresses ) );
echo $new_rss;
?>