[Pligg 8.2.0] Submit a feed automatically : The recap

Register an Account
Pligg Chat Room
Closed Thread
 
LinkBack Thread Tools Display Modes
  #41 (permalink)  
Old 06-26-2006, 12:06 PM
juicecowboy's Avatar
Casual Pligger
 
Join Date: Jun 2006
Location: San Jose, CA
Posts: 53
Send a message via Yahoo to juicecowboy
Quote:
Originally Posted by 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?
I just limited the import with an "if...then" statement in the script. This works fine.

Here is the script with a limit on the number of import (in this case "3")...doesn't really get more simple than this...

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

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

$rss_feeds=array (
        array(
                
'url'=>"http://www.sfgate.com/rss/feeds/wine.xml",
                
'category'=>8,
                
'author'=>19,
//              'tags'=>'
        
),
        array(
                
'url'=>"http://feeds.feedburner.com/VivisWineJournal",
                
'category'=>9,
                
'author'=>15,
//              '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 
{

if (
$i <= 3)
     {
        
$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>";
    }
     
$i++;

}
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";
}


?>
  #42 (permalink)  
Old 06-26-2006, 07:33 PM
New Pligger
 
Join Date: Jun 2006
Posts: 23
I know I am doing something stupid but I ge this error:

/home/sports/public_html/cbs_nfl.php: line 1: ?
: No such file or directory
/home/sports/public_html/cbs_nfl.php: line 2: syntax error near unexpected token `'rss_fetch.inc''
/home/sports/public_html/cbs_nfl.php: line 2: `require('rss_fetch.inc'); '


Here is my code:
Code:
<?
require('rss_fetch.inc');

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

$rss_feeds=array (
        array(
                'url'=>"http://cbs.sportsline.com/partners/feeds/rss/nfl_news",
                'category'=>27,
                'author'=>15,
//              '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";
}


?>

Last edited by kevinrstruck; 06-26-2006 at 07:41 PM.
  #43 (permalink)  
Old 06-26-2006, 08:17 PM
juicecowboy's Avatar
Casual Pligger
 
Join Date: Jun 2006
Location: San Jose, CA
Posts: 53
Send a message via Yahoo to juicecowboy
Did you install MagpieRSS? That is the pre-req (rss-fetch.php is part of Magpie)...
  #44 (permalink)  
Old 06-26-2006, 09:31 PM
New Pligger
 
Join Date: Jun 2006
Posts: 23
Yes it is installed.
  #45 (permalink)  
Old 07-11-2006, 02:50 PM
chuckroast's Avatar
Pligg Developer/Coder/Designer
Pligg Version: SVN
Pligg Template: Galleria
 
Join Date: Jun 2006
Posts: 3,828
I've been working on this for a couple days and I keep running into the same problem... The feeds I am using are all rss 2.0 validated with no crazy HTML or anything but the script keeps "Skipping" everything...


-----------------------------------------------------
# Processing RSS-Feed 1
Skipped
# Finished Processing RSS-Feed 1
-----------------------------------------------------



I have magpierss working correctly meaning I can open these feeds fine through the server and display them on a php page with the sample code for magpierss...

Anyone out there that can shed some light on this?

I've even tried using "refeed" and pulled all the rss into a msql database and then parsed them back out as rss 1 and atom and still get the same skipping result when I run this script....

Signed
Frustrated Geek
  #46 (permalink)  
Old 07-16-2006, 01:02 AM
New Pligger
 
Join Date: Jul 2006
Posts: 8
Thanks for the mod. Works like a champ
  #47 (permalink)  
Old 07-20-2006, 05:09 AM
New Pligger
 
Join Date: Jul 2006
Posts: 4
Have you got some news about this mod? I try to insert a loop in order to have more than one feed but i have some bugs for the moment.

If you have an idea, please post it on this forum, thanks a lot.
  #48 (permalink)  
Old 07-20-2006, 05:30 AM
New Pligger
 
Join Date: Jul 2006
Posts: 4
I just try to insert a loop, but no way.... An idea ?

I have an error an 41 line :

Fatal error: Call to undefined function: rss_store() in /home.10.2/eroclic/www/beta/magpierss/import.php on line 41

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

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

    include('connexion.php');
	$table="import";
	$query = "SELECT * FROM $table"; 
	$result = mysql_query($query);
	while ($val = mysql_fetch_array($result)) 
	{ 
	

$rss_feeds=array(
			array(
					'url'=>$val["url_import"],
					'category'=>$val["category_import"],
					'author'=>$val["author_import"],
					'tags'=>$val["tags_import"]
			),
);

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 )
{

if ($i <= 3)
    {
        $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>";
    }
    $i++;

}
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";
}
}
?> 
  #49 (permalink)  
Old 07-24-2006, 03:10 PM
AshDigg's Avatar
Mayor of PliggVille/Coder
 
Join Date: Dec 2005
Posts: 1,515
I'm currently working on integrating this into the admin panel for the latest version of pligg. Hope to have something ready by the end of the week.
  #50 (permalink)  
Old 07-24-2006, 05:34 PM
Casual Pligger
 
Join Date: Jun 2006
Posts: 55
I'm looking forward to this one, AshDigg.
Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to automatically check for updates in rss feed? marcinpl87 Questions and Comments 3 01-14-2010 12:06 AM
Some ideas to build a Pligg site Divisive Cotton Questions and Comments 22 10-22-2009 10:46 AM
Auto submit story on submit step 3 for god only gnalkit Questions and Comments 2 10-13-2009 08:47 AM
RSS Import Feed - Feed Frequency Not working ant560 Questions and Comments 4 03-15-2008 04:31 AM
Import RSS Auto submit feed argh2xxx Questions and Comments 12 09-12-2007 04:02 PM


Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development