Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Closed Thread
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 03-31-2006, 02:20 AM
dwg dwg is offline
New Pligger
 
Join Date: Mar 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Using Magpierss, here is something quick and dirty that seems to work for me. Not sure how to get the tags inserted, but the rest should work. Just set it up as a cron.

Code:
<?
require('../magpierss/rss_fetch.inc');

include('config.php');
require(mnminclude.'link.php');

$rss_feeds=array (
        array(
                'url'=>"http://digg.com/rss/index.xml",
                'category'=>7,
                'author'=>16,
//              'tags'=>'
        ),
);


echo "<ul>\n";
foreach ($rss_feeds as $feed ) {
$rss = fetch_rss($feed['url']);
echo "<li>Site: ", $rss->channel['title'], "<br>\n";
foreach ($rss->items as $item ) {
        $item['author']=$feed['author'];
        $item['category']=$feed['category'];
 
        $title = $item[title];
        $desc= $item[description];

        echo "<ul>";
        echo "<li>Processing <a href=$url>$title</a></li>\n";
        rss_store($item);
        echo "<li>Finished Processing <a href=$url>$title</a></li><br><br/>\n\n";
        echo "</ul>";

}

echo "</li>";
}
echo "</ul>";


function rss_store($item) {

        $linkres=new Link;

        $edit = false;
        $linkres->get(trim($item['link']));

        if(!$linkres->valid) {
                rss_error($item['link']);
                return;
        }

        if($linkres->duplicates($item['link']) > 0) {
                rss_error($item['url']);
                return;
        }
        $linkres->status='discard';
        $linkres->author=$item['author'];

        $linkres->title=$item['title'];
        $linkres->content=$item['description'];


        $linkres->id=0;
        $linkres->category=$item['category'];
        $linkres->randkey=rand(10000,10000000);
        $linkres->read();
        $linkres->status='queued';
        $linkres->store();
        return;
}

function rss_error($url){
        echo "Skipped $url <br/>\n";
}


?>
  #12 (permalink)  
Old 03-31-2006, 12:17 PM
New Pligger
 
Join Date: Mar 2006
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
So I can just name this script whatever I want, change the rss feed source, and run it as a cron?
  #13 (permalink)  
Old 03-31-2006, 02:41 PM
dwg dwg is offline
New Pligger
 
Join Date: Mar 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
Yep...although you should have your cron have something like ' >/dev/null 2>&1' at the end so it doesn't capture any of the output. You can add as many rss feed sources as you want, just add an additional array to $rss_feeds.
  #14 (permalink)  
Old 04-03-2006, 02:58 AM
Casual Pligger
 
Join Date: Jan 2006
Posts: 33
Thanks: 37
Thanked 0 Times in 0 Posts
nice job dwg
but i want to ask how to set a cron job in Magpie?
  #15 (permalink)  
Old 04-03-2006, 06:32 AM
New Pligger
 
Join Date: Apr 2006
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Running PHP Scripts with Cron

Xanatos.. Cron is normally available on all Unix and Linux distributions. Here is a nice tutorial about running PHP scripts with Cron

http://www.htmlcenter.com/tutorials/...s.cfm/155/PHP/
  #16 (permalink)  
Old 04-05-2006, 10:14 AM
Casual Pligger
 
Join Date: Jan 2006
Posts: 33
Thanks: 37
Thanked 0 Times in 0 Posts
sorry user008 i still dont understanding how to set cron job
could anyone teach me step by step??
  #17 (permalink)  
Old 04-08-2006, 02:10 PM
Casual Pligger
 
Join Date: Jan 2006
Posts: 33
Thanks: 37
Thanked 0 Times in 0 Posts
i think i know how to set a cron job now
thx user008
  #18 (permalink)  
Old 04-08-2006, 08:07 PM
Constant Pligger
 
Join Date: Jan 2006
Posts: 197
Thanks: 1
Thanked 0 Times in 0 Posts
DWG, with your method, what shows up as the poster?
  #19 (permalink)  
Old 04-10-2006, 11:17 AM
dwg dwg is offline
New Pligger
 
Join Date: Mar 2006
Posts: 19
Thanks: 0
Thanked 0 Times in 0 Posts
The poster is whoever's author id you set in the settings for the RSS feed:

$rss_feeds=array (
array(
'url'=>"http://digg.com/rss/index.xml",
'category'=>7,
'author'=>16,
// 'tags'=>'
),
);

So, for the above, whichever user has the id=16 is considered the author.
  #20 (permalink)  
Old 04-20-2006, 03:26 AM
New Pligger
 
Join Date: Apr 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
dwg,

Your mod is working great for some feeds and not others. For example:

Works:
http://rss.teamxbox.com/news/xbox-360.rss

Does not work:
http://scripts.gamespy.com/rss/gamespy.PC.2.0.xml

I don't get any error messages on the non working feed. Just a blank page when I send the feed through your mod.

Any ideas?
Closed Thread

Thread Tools
Display Modes
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to automatically check for updates in rss feed? marcinpl87 Module Support 2 06-26-2008 04:17 AM
Some ideas to build a Pligg site Divisive Cotton Off-topic 20 06-03-2008 04:09 PM
RSS Import Feed - Feed Frequency Not working ant560 Installation and Upgrade Help 4 03-15-2008 04:31 AM
Import RSS Auto submit feed argh2xxx Modification Tutorials 12 09-12-2007 04:02 PM
[Fixed] Import RSS feed not update automatically smart Bug Report 11 03-06-2007 12:36 PM


Search Engine Friendly URLs by vBSEO 3.2.0