Jump to content

jcombs_31

Staff Alumni
  • Posts

    2,064
  • Joined

  • Last visited

Posts posted by jcombs_31

  1. Oh yeah, in case you were wondering, you can see this in action at http://www.movie-gurus.com/ in that the News section is the data pulled from the feeds.  You have to click on a news item to get to the abstract view for a story, but that small paragraph is what gets pulled in in the description.

    183876[/snapback]

     

    I didn't realize I could just add an $item['description']. Now I'm gettin where I wanna be.

     

    thanks for your feedback.

  2. I looked at Magpie and decided it was a bit heavier than what I wanted.  I opted instead to use this class:  LastRSS.

     

    It probably works in a similar manner to magpie.  Here's some sample code that I used, to give you an idea.

     

    $rss = new lastRSS();
    if ($rs = $rss->Get('http://... put url of xml feed here'')) {
    $dbh = mysql_connect($DBHOST, $DBUSER, $DBPWD) or die();
    mysql_select_db($DBDB);
    if ($rs['items_count'] > 0) {
     for ($i=$rs['items_count']-1; $i--; $i >= 0) {
     	$item = $rs['items'][$i];
     	foreach ($item as $key => $value)
       $item[$key] = addslashes($value);
     	//YYYY-MM-DD HH:MM:SS (MYSQL FORMAT)
     	$pubdate = date('Y-m-d h:i:s', strtotime($item['pubDate']));
     	if (!empty($item['guid'])) {
       $sql = "SELECT COUNT(*) AS countof FROM mg_news WHERE guid = '$item[guid]'";
     	} else {
       $sql = "SELECT COUNT(*) AS countof FROM mg_news WHERE url = '$item[link]'";
     	}
     	echo "$sql<br \>";
     	$rslt = mysql_query($sql, $dbh) or die(MYSQL_ERROR());
     	$row = mysql_fetch_assoc($rslt);
     	//Tue, 14 Sep 2004 22:21:39
     	if ($row['countof'] == 0) {  	
       $sql = 'INSERT INTO mg_news (mg_newssource_id, int_state, guid, date, subject, news, url) VALUES (';
       $sql .= "$nsid, $defstate, '$item[guid]', '$pubdate', '$item[title]', '$item[description]', '$item[link]')";
       $rslt = mysql_query($sql, $dbh);
       echo "$sql<br \>";
     	} else {
       echo 'Guid or Link exists, skipping<br \>';
     	} 
     }
    }
    } else {
    echo 'Uh oh, didn\'t work';
    }
    

     

    As you should note from my example, the entire purpose of my use here was to get the information into a database table.  There are a lot of alternative methods to doing that, which includes the caching to file method.

     

    I don't worry about that because I control when this script goes out to the the site and pulls information via cron.  They have simpler examples in their documentation.

     

    The problem with your writing your cache file is probably a permissions issue.  Remember that the webserver process is the one that is writing the file to disk, so you need to make sure that the permissions on the cache directory are such that the webserver user has read/write to that directory.

    183872[/snapback]

     

    Thanks, I fixed the permissions issue, but still I want to have a script that gives glipse at the content of the feed, not just the link. I have much smaller script than magpe that does the same thing.

     

  3. Thanks, does this have the ability to display some data in the feed rather than just a link?

     

    I used the code in the readme file

     

    <?php 
    require_once('includes/rss_fetch.inc');
    $url = "http://www.lockergnome.com/rss/web.php";
    $rss = fetch_rss( $url );
    
    echo "Channel Title: " . $rss->channel['title'] . "<p>";
    echo "<ul>";
    foreach ($rss->items as $item) {
     $href = $item['link'];
     $title = $item['title'];
     echo "<li><a href=$href>$title</a></li>";
    }
    echo "</ul>";
    
    ?>
    

     

    and get the links to a feed, but then have a cache error

     

    "Cache couldn't make dir './cache'. Cache unable to open file for writing: ./cache\039d3bbd5586f0089b4edc1d921dbe72"

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.