Link Trading
  Home arrow Link Trading arrow Page 3 - Using RSS Feeds and Mod_rewrite to add...
SEO Chat Forums  
Choosing Keywords  
Google Optimization  
Link Trading  
MSN Optimization  
Search Engine News  
Search Engine Spiders  
Search Optimization  
Web Directories  
Website Marketing  
Website Promotion  
Website Submission  
Yahoo Optimization  
SEO Tools
Adsense Calculator
AdSense Preview
Advanced Meta-Tags
Alexa Rank Tool
Check Server Headers
Class C Checker
Code to Text Ratio
CPM Calculator
Domain Age Check
Domain Typos
Future PageRank
Google Dance
Google Keywords
Google Search
Google Suggest
Google vs Yahoo
Indexed Pages
Keyword Cloud
Keyword Density
Keyword Difficulty
Keyword Optimizer
Keyword Position
Keyword Typos
Link Popularity
Link Price Calculator
Meta Analyzer
Meta Tag Generator
Multiple Link Popularity
Page Comparison
Page Size
PageRank Lookup
PageRank Search
Robots.txt Generator
ROI Calculator 
S.E. Comparison 
S.E. Keyword Position 
Site Link Analyzer 
Spider Simulator 
URL Redirect Check 
URL Rewriting 
Mobile Linux 
APP Generation ROI 
IBM® developerWorks 
SEO Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
LINK TRADING

Using RSS Feeds and Mod_rewrite to add Classified Listings on your Website
By: Roger Stringer
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 14
    2005-08-22

    Table of Contents:
  • Using RSS Feeds and Mod_rewrite to add Classified Listings on your Website
  • Arrays of cities and categories
  • Four functions
  • Putting it all together

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Using RSS Feeds and Mod_rewrite to add Classified Listings on your Website - Four functions


    (Page 3 of 4 )

    There are also four functions used in rssads.php.

    The first function is called "listCities." This function runs through our cities array and displays a page of cities, grouped by country. This is used on the main page of our site:

    <?
      function listCities($cities){
        echo "<table width=100%>";
        foreach($cities as $country=>$list){
          echo "<tr><td colspan=3>".$country."</td></tr>";
          $i = 0;
          foreach($list as $k=>$city){
            $i++;
            if($i == 1)echo "<tr>"; 
            echo "<td width=33%><a href=\"ads/".urlencode($city)."/\">".$city."</a></td>";
            if($i == 3){
              echo "</tr>";
              $i = 0;
            }
          }
        }
        echo "</table>";
      }
    ?>

    Our next function is called "listCats." It works like listCities, and creates a list of categories:

    <?
      function listCats($city,$categories){
        echo "<table width=100%>";
        foreach($categories as $parent=>$list){
          echo "<tr><td colspan=3 align=center>".
    $parent."</td></tr>";
          $i = 0;
          foreach($list as $cat=>$name){
            $i++;
            if($i == 1)echo "<tr>";
            echo "<td width=33%><a href=\"ads/".urlencode($city)."/".urlencode($cat)."/\">".$name."</a></td>";
            if($i == 3){
              echo "</tr>";
              $i = 0;
            } 
          } 
        }
        echo "</table>";
      }
    ?>

    Our third function is called "display." It processes the city and category and then calls our final function:

    <?
      function display($city,$cat,$categories){
        $ocity = $city;
        $city = explode(",",$city);
        $city = $city[0];
        $city = str_replace(" ","",$city);
        $url = "http://".$city.".craigslist.org/".
    $cat."/index.rss";
        foreach($categories as $parent=>$list){
          if( isset($list[$cat]) ){
            $tname = $parent." - ".$list[$cat];
            break;
          }
        }
        $ptitle = "craigslist | Displaying ".$tname." jobs in ".$ocity;
    ?>
            <a href="<?=str_replace("index.rss","",$url)?>"><?=$ptitle?></a><br/>
    <?  
        echo readRss($url);
      }
    ?>

    Our final function is the backbone of this site, "readRSS." It is a universal RSS reader function that serves quite well for fetching RSS feeds from craiglist.org for us. Basically, it fetches the RSS feed that the script tells it to fetch and returns with information related to the feeds. In our case, it returns ads:

    <?
      function readRss($url){
    ?>
        <table width='100%'>
    <? 
        $row = @implode( '',@file($url) );
        if( preg_match_all("'<item[^>]*>.*?</item(s?)>'si", $row, $rowitem ) ) {
          $item = $rowitem[0];
          $res = "";
          $total = count($item) - 1;
          for( $i = 0; $i < $total; $i++ ) {
            if (trim($item[$i])!='' and !ereg('<items',$item[$i])) {
              eregi('<title>(.*)</title>', $item[$i], $title );
              eregi('<link>(.*)</link>', $item[$i], $url );
              eregi('<description>(.*)</description>', $item[$i], $desc );
              echo "<tr><td>";
              echo "<a href='".str_replace("&","&",$url[1]).
                   "'>".$title[1]."</a><span><br>".
                   "<div style='padding-left:10px;'>".
                   htmlspecialchars( trim($desc[1]) ).
                   "</div><br>";
              echo "</td></tr>";
            } 
          } 
        }
    ?>
        </table>
    <?
      }
    ?>

    More Link Trading Articles
    More By Roger Stringer


       · Hopefully this isn't going to give away the farm, but I have a few questions...
       · Hello! there. I read the article and i want to try it but i could not set up...
       · Did you set up the .htaccess file like I said at the start of the article?
       · Yes.. I'm using the following lines on my...
       · Does your server have mod_rewrite turned on / installed?One thing to try, find...
       · I just figured out that i was doing a mistake on "rssads.php"...
       · But this clearly violates CraigsList TOS regarding aggregation/reproduction. This...
       · Using the RSS feeds from craigslist does not violate their TOS. If it does, then it...
     

    LINK TRADING ARTICLES

    - Proven Link Building Strategies that Work
    - Analyzing Inbound Links Using BacklinkWatch ...
    - Page Quality Factors for Link Building
    - Article Writing for Back-Links
    - Requesting One-Way Links
    - Link Building Tips From Experts
    - Link Building: The Anchor Text
    - SEO and Link Building: Good and Bad Plans
    - Link Building Methods
    - Link Trading: Good Idea, or Waste of Time?
    - Establishing Link Popularity and Increasing ...
    - Microsites for Affiliates and SEO
    - A Brave New World: the Current and Future St...
    - The Importance of Building Links
    - Link Farming: No Good Harvest





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 6 Hosted by Hostway
    For more Enterprise Application Development news, visit eWeek