-1

我正在使用它来生成 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)); ?>
4

2 回答 2

2

你没有关闭附件标签,添加一个</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));

?>
于 2012-07-16T07:03:23.073 回答
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;

?>
于 2012-07-16T07:07:15.733 回答