Go Back   Pligg CMS Forum > Pligg Development > Modification Tutorials

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: 57
Thanks: 1
Thanked 0 Times in 0 Posts
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
Casual Pligger
 
Join Date: Jun 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
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: 57
Thanks: 1
Thanked 0 Times in 0 Posts
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
Casual Pligger
 
Join Date: Jun 2006
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Yes it is installed.
  #45 (permalink)  
Old 07-11-2006, 02:50 PM
chuckroast's Avatar
Coder/Designer
Pligg Version: 1.0
Pligg Template: ExpertVision
 
Join Date: Jun 2006
Location: PA
Posts: 2,399
Thanks: 171
Thanked 439 Times in 278 Posts
Arrow RSS Feeds

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: 9
Thanks: 1
Thanked 0 Times in 0 Posts
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
Thanks: 0
Thanked 0 Times in 0 Posts
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
Thanks: 0
Thanked 0 Times in 0 Posts
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
Coder
 
Join Date: Dec 2005
Posts: 1,574
Thanks: 235
Thanked 345 Times in 206 Posts
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.
__________________
- Ash
  #50 (permalink)  
Old 07-24-2006, 05:34 PM
Casual Pligger
 
Join Date: Jun 2006
Posts: 64
Thanks: 0
Thanked 0 Times in 0 Posts
I'm looking forward to this one, AshDigg.
__________________
TravelScoop
(Pligg Contributor)
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