Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

Closed Thread
 
LinkBack Thread Tools Display Modes
  #31 (permalink)  
Old 06-06-2006, 10:40 PM
New Pligger
 
Join Date: Jun 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Does this code check for duplicate links? I can have the cron job run once a day, but if the RSS is not updated, would it add the links again or just ignore the old links and add new links, if any?

Thanks

Quote:
Originally Posted by dwg
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";
}


?>
  #32 (permalink)  
Old 06-07-2006, 12:37 AM
New Pligger
 
Join Date: Jun 2006
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
never mind. Find out that it does check for duplicates, which is great!!
  #33 (permalink)  
Old 06-08-2006, 04:58 PM
New Pligger
 
Join Date: May 2006
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
any chance you could make it so anything submited by feeds is automatically published?
  #34 (permalink)  
Old 06-12-2006, 01:09 AM
New Pligger
 
Join Date: May 2006
Posts: 16
Thanks: 0
Thanked 0 Times in 0 Posts
im getting an error message. any one know how to help me?

Warning: require(/magpierss/rss_fetch.inc) [function.require]: failed to open stream: No such file or directory in /home/.dickon/crackers1/www.bombconstruction.com/rssfeed.php on line 5

Fatal error: require() [function.require]: Failed opening required '/magpierss/rss_fetch.inc' (include_path='.:/usr/local/php5/lib/php') in /home/.dickon/crackers1/www.bombconstruction.com/rssfeed.php on line 5

*EDIT**************

it magically works now.. mmhmm... okay...

http://bombconstruction.com/shakeit.php

have a look at some of the article titles... eg...
Lilly: Drug cuts diabetics' %&#vision loss - CNN

how do i fix that?

Last edited by crackah; 06-12-2006 at 02:39 AM..
  #35 (permalink)  
Old 06-12-2006, 11:21 AM
Casual Pligger
 
Join Date: May 2006
Posts: 75
Thanks: 0
Thanked 4 Times in 2 Posts
OK, so I need to install Magpie for this?
  #36 (permalink)  
Old 06-12-2006, 12:59 PM
savant's Avatar
Constant Pligger
 
Join Date: Apr 2006
Location: UK
Posts: 1,218
Thanks: 64
Thanked 207 Times in 148 Posts
crackah

the url seems to be encoded.
when it is out it should be decoded.

try this:

/libs/link.php

$smarty->assign('url_short', $url_short);

replace this with

$smarty->assign('url_short', urldecode($url_short));

but i dunno how safe that is.
will find out.
  #37 (permalink)  
Old 06-12-2006, 07:08 PM
New Pligger
 
Join Date: Apr 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
I got this error when setting a cron jobs..

/bin/sh: line 1: www.domain.com/magpierss/mycronjob.php: No such file or directory

question :
How do i set a cron job ?
do i need to point to that phpfile ?
__________________
http://www.kablogs.com - Blogging related news
http://www.myhobbyhq.com - My Hobbies Do you have one?
http://myhobbyhq.com/airsoftblog - About Airsoft Guns - tips, upgrades, do it yourself.
  #38 (permalink)  
Old 06-14-2006, 06:22 PM
New Pligger
 
Join Date: Apr 2006
Posts: 29
Thanks: 0
Thanked 0 Times in 0 Posts
Finally It worked, my path is incorrect thats why i encountered my problem

thanks...

how can I limit the amount of item to be posted for example
I only want to get 3 items per site.
__________________
http://www.kablogs.com - Blogging related news
http://www.myhobbyhq.com - My Hobbies Do you have one?
http://myhobbyhq.com/airsoftblog - About Airsoft Guns - tips, upgrades, do it yourself.
  #39 (permalink)  
Old 06-20-2006, 07:44 AM
Casual Pligger
 
Join Date: Jan 2006
Posts: 77
Thanks: 0
Thanked 1 Time in 1 Post
hmm I wonder if you could have it post but tag it as a discarded story so it does not show up.. then.. with some kind of admin panel.. go in and have a looksy what it is giving you under that user name.. tick the ones you want to show up.. and un discard them.. edit the titles etc before introducing them... a little more work but gives the more human look to them.. no??
  #40 (permalink)  
Old 06-24-2006, 11:58 AM
juicecowboy's Avatar
Casual Pligger
 
Join Date: Jun 2006
Location: San Jose, CA
Posts: 57
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via Yahoo to juicecowboy
Need help with this--

It works excellent. one thing - on initial import, there are like 10 stories. I usually discard many of them (so that user-submitted stories don't get buried in the queue). On the next import, it picks up the "discard" stories again and puts them in the queue. It makes for alot of work with mysqladmin but if the script could include "discarded" stories in the duplicate checking that would be great.

I'm not much of a coder but I'm hoping this isn't hard. Could someone give me a quick tutorial on how to make this script check queued and discard stories?
__________________

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