RSS Injector available

Started by confusion, December 24, 2005, 04:04:48 PM

Previous topic - Next topic

TechnoDragon

Probably becasue oif the way the rss feed is provided...even though you can add mulitple rss feedss to the news file, you might try creating different files with different names (news.php does not need to be named that and no editing is required if you change the file name), that way you can independently run the feeds if you like rather than run them all at once.

Plus after you run the file(s) make sure to go to the admin section and run recount forum totals and find and fix errors...

lastly...if anyone can figure out how to make the posts from this show up as new in the recent posts (TP uses a block for this) I would be greatly appreciative.
Don't tell me to get into shape...I have a shape...It is round!


daveso

Yes...I want to put the feeds into a topic. I appreciate the offer on helping me do this.
Where do we start?
Did I say thank you ?
thanks :)

Quote from: technodragon73 on March 19, 2006, 01:22:22 PM
If you run SMF with say Tiny Portal and no mods it is a very user friendly system...the majority of the talk here is for modifying the forum do do more than it was coded to do.

If you are looking for just an rss feed, you can use a package called Tiny Portal (www.tinyportal.net) and it uses an easy system of "blocks" one of which is designed to do rss feeds.

If you are looking to have the feeds entered into your forum as topics and posts that is what this is for and I can help you with the setup if you like.

Also,most of the files that ever need to be modified are usually in one of two places...either the sources directory or the default theme directory.

TechnoDragon

Quote from: daveso on March 20, 2006, 05:40:12 PM
Yes...I want to put the feeds into a topic. I appreciate the offer on helping me do this.
Where do we start?
Did I say thank you ?
thanks :)

Quote from: technodragon73 on March 19, 2006, 01:22:22 PM
If you run SMF with say Tiny Portal and no mods it is a very user friendly system...the majority of the talk here is for modifying the forum do do more than it was coded to do.

If you are looking for just an rss feed, you can use a package called Tiny Portal (www.tinyportal.net) and it uses an easy system of "blocks" one of which is designed to do rss feeds.

If you are looking to have the feeds entered into your forum as topics and posts that is what this is for and I can help you with the setup if you like.

Also,most of the files that ever need to be modified are usually in one of two places...either the sources directory or the default theme directory.

Hmmmm...well, you could contact me on msn and i can send you the files you need from there since you cannot attach anything in this topic.
Don't tell me to get into shape...I have a shape...It is round!


L.G.S

Hmm I need help please.

I have filled everything out, checked the board number, userID, and the database prefix.

I use the file and I get a blank page, but nothing happens to my forum :(
FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


TechnoDragon

post a link to the site so i can take a look
Don't tell me to get into shape...I have a shape...It is round!


Xarcell


TechnoDragon

Not true...that is the version of SMF i am using.
Don't tell me to get into shape...I have a shape...It is round!


JSalvador

I first of all... Awesome work!  I'm really impressed. Got the script to work and it works great!!!

I've got two questions.

1) is there a way to batch enter in RSS feeds? that way a person would only have to run the news.php file once.

2) is there a way to automate this script so that it retrieves the RSS items and converts them to posts as they come?
hxxp:www.naturalencyclopedia.com [nonactive]
hxxp:www.likeadove.com [nonactive]

L.G.S

FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


TechnoDragon

Quote from: L.G.S on March 22, 2006, 11:58:48 AM
Quote from: technodragon73 on March 21, 2006, 08:38:29 PM
post a link to the site so i can take a look

http://www.tactical-illusion.com/board

should be going into the sport area.

do you have a test account?

that way i can view the booard and topics.
Don't tell me to get into shape...I have a shape...It is round!


Xarcell

What am I doing wrong then? I can't seem to get it to work, and I want it to work so bad...

Quote
<?php
//
// SMF RSS Injector by Jerry Bell - [email protected]
// Based on the Joomla RSS import script by Max Soukhomlinov, [email protected]
//
// This script requires XML_RSS and PHP Pear Libraries
//
//
// This script is quick and dirty. Please remember to abide by the RSS content providers' terms of use.

/** the PEAR XML_RSS object/class is required */
require 'RSS.php';

/** DATABASE Configuration */
define("DB_HOSTNAME","360.xboxnarc.com"); //Insert your DB server name here
define("DB_USERNAME","narcmaster"); //DB username here
define("DB_PASSWD","*********"); // DB password here
define("DB_DATABASE","gamemod"); //DB name here
$userid = 4; //Set this to the SMF userid you want the messages posted from
$boardid = 35;//Set this to the id of the board you want to post the messages in

/** pull list of remote RSS feeds, via a remote RSS feed. */
$rss_feed = & new XML_RSS('http://rss.gamespot.com/misc/rss/gamespot_updates_xbox_360.xml'); //Insert your URL here
//$rss_feed = & new XML_RSS('feed.xml'); //Used this for testing with local file, a bit quicker
// Function for shortening articles based on maximum length
function str_stop($string, $max_length){
   if (strlen($string) > $max_length){
       $string = substr($string, 0, $max_length);
       $pos = strrpos($string, " ");
       if($pos === false) {return substr($string, 0, $max_length)."...";}
       return substr($string, 0, $pos)."...";
   }else{return $string;}
}
/** create the database connection object */
$obj_db = @mysql_connect(DB_HOSTNAME,DB_USERNAME,DB_PASSWD) or die (mysql_error());

/** select the intended database */
@mysql_select_db(DB_DATABASE,$obj_db) or die (mysql_error());

$rss_feed->parse();

      $num_articles=0; //Variable used to count number of new articles, displayed in an email below

    // Here we make sure that feed articles do not already exist in DB
    // this uses title names, make sure to use the same title formatting here as you will use further down
    // state = 1 not trashed
    foreach ($rss_feed->getItems() as $item) {
        $obj_query = @mysql_query("
            SELECT
                COUNT(ID_MSG) AS link_match
            FROM
                messages
            WHERE
                subject = '". str_stop(addslashes($item['title']),100) ."'
        ",$obj_db) or die(mysql_error());

        $int_count = @mysql_fetch_assoc($obj_query) or die(mysql_error());

        mysql_free_result($obj_query);

        if ($int_count['link_match'] == 0) {

          $num_articles = $num_articles +1;
         /**
          * REFORMATTING CODE
          **/
// In my experience you have to play with the definitions from different RSS feeds - some rss feeds call fields different things.
      $titletext = str_stop(addslashes($item['title']),100);
// This adds an html link at to the original article at the very bottom of the post.
      $maintext = addslashes($item['description']) . "<p><a href=\"" . $item['link'] . "\">" . $item['link'] . "</a>";
    @mysql_query("
         INSERT INTO topics(
            ID_BOARD,
            ID_MEMBER_STARTED,
            ID_MEMBER_UPDATED
         ) VALUES (
            '$boardid',
            '$userid',
            '$userid'
         )
      ",$obj_db) or die(mysql_error());
$topic = mysql_insert_id();
$postertime = date('U');
//Insert the actual message
    @mysql_query("
         INSERT INTO messages(
            subject,
            body,
             ID_MEMBER,
            ID_BOARD,
            ID_TOPIC,
            posterTime
         ) VALUES (
            '". $titletext ."',
            '". $maintext ."',
            '$userid',
            '$boardid',
            '$topic',
            '$postertime'
         )
      ",$obj_db) or die(mysql_error());
$messageid = mysql_insert_id();
//Go back and set ID_FIRST_MSG and ID_LAST_MSG in the topics table
    @mysql_query("
         UPDATE topics
            SET ID_FIRST_MSG = '$messageid',
            ID_LAST_MSG = '$messageid'
            WHERE ID_TOPIC = '$topic'
      ",$obj_db) or die(mysql_error());
//Increment total posts for board
    @mysql_query("
         UPDATE boards
            SET numPosts = numPosts + 1,
            numTopics = numTopics + 1
            WHERE ID_BOARD = '$boardid'
      ",$obj_db) or die(mysql_error());
//Increment Total Messages
    @mysql_query("
         UPDATE settings
            SET value = value + 1
            WHERE variable = 'totalMessages'
      ",$obj_db) or die(mysql_error());
//Increment Total Topics
    @mysql_query("
         UPDATE settings
            SET value = value + 1
            WHERE variable = 'totalTopics'
      ",$obj_db) or die(mysql_error());
// Increment post count for user record
    @mysql_query("
                        UPDATE members
                        SET posts = posts + 1
                                WHERE ID_MEMBER = '$userid'
                ",$obj_db) or die(mysql_error());
        }
    }

if ($obj_db) {
    @mysql_close($obj_db);
}
?>
[/qoute]

TechnoDragon

I am so sorry Xarcell...I did not realize you were looking for help as well, you are usually the helper...lol

It looks to me like you are missing the prefix for your tables in the body of the code....

try this (you obviously need to put your password in and this is assuming that you are using the smf_ prefix):

<?php
//
// SMF RSS Injector by Jerry Bell - [email protected]
// Based on the Joomla RSS import script by Max Soukhomlinov, [email protected]
//
// This script requires XML_RSS and PHP Pear Libraries
//
//
// This script is quick and dirty. Please remember to abide by the RSS content providers' terms of use.

/** the PEAR XML_RSS object/class is required */
require 'RSS.php';

/** DATABASE Configuration */
define("DB_HOSTNAME","360.xboxnarc.com"); //Insert your DB server name here
define("DB_USERNAME","narcmaster"); //DB username here
define("DB_PASSWD","*********"); // DB password here
define("DB_DATABASE","gamemod"); //DB name here
$userid 4//Set this to the SMF userid you want the messages posted from
$boardid 35;//Set this to the id of the board you want to post the messages in

/** pull list of remote RSS feeds, via a remote RSS feed. */
$rss_feed = & new XML_RSS('http://rss.gamespot.com/misc/rss/gamespot_updates_xbox_360.xml'); //Insert your URL here
//$rss_feed = & new XML_RSS('feed.xml'); //Used this for testing with local file, a bit quicker
// Function for shortening articles based on maximum length
function str_stop($string$max_length){
   if (
strlen($string) > $max_length){
       
$string substr($string0$max_length);
       
$pos strrpos($string" ");
       if(
$pos === false) {return substr($string0$max_length)."...";}
       return 
substr($string0$pos)."...";
   }else{return 
$string;}
}
/** create the database connection object */
$obj_db = @mysql_connect(DB_HOSTNAME,DB_USERNAME,DB_PASSWD) or die (mysql_error());

/** select the intended database */
@mysql_select_db(DB_DATABASE,$obj_db) or die (mysql_error());

$rss_feed->parse();

      
$num_articles=0//Variable used to count number of new articles, displayed in an email below

    // Here we make sure that feed articles do not already exist in DB
    // this uses title names, make sure to use the same title formatting here as you will use further down
    // state = 1 not trashed
    
foreach ($rss_feed->getItems() as $item) {
        
$obj_query = @mysql_query("
            SELECT
                COUNT(ID_MSG) AS link_match
            FROM
                smf_messages
            WHERE
                subject = '"
str_stop(addslashes($item['title']),100) ."'
        "
,$obj_db) or die(mysql_error());

        
$int_count = @mysql_fetch_assoc($obj_query) or die(mysql_error());

        
mysql_free_result($obj_query);

        if (
$int_count['link_match'] == 0) {

          
$num_articles $num_articles +1;
         
/**
          * REFORMATTING CODE
          **/
// In my experience you have to play with the definitions from different RSS feeds - some rss feeds call fields different things.
      
$titletext str_stop(addslashes($item['title']),100);
// This adds an html link at to the original article at the very bottom of the post.
      
$maintext addslashes($item['description']) . "<p><a href=\"" $item['link'] . "\">" $item['link'] . "</a>";
    @
mysql_query("
         INSERT INTO smf_topics(
            ID_BOARD,
            ID_MEMBER_STARTED,
            ID_MEMBER_UPDATED
         ) VALUES (
            '
$boardid',
            '
$userid',
            '
$userid'
         )
      "
,$obj_db) or die(mysql_error());
$topic mysql_insert_id();
$postertime date('U');
//Insert the actual message
    
@mysql_query("
         INSERT INTO smf_messages(
            subject,
            body,
             ID_MEMBER,
            ID_BOARD,
            ID_TOPIC,
            posterTime
         ) VALUES (
            '"
$titletext ."',
            '"
$maintext ."',
            '
$userid',
            '
$boardid',
            '
$topic',
            '
$postertime'
         )
      "
,$obj_db) or die(mysql_error());
$messageid mysql_insert_id();
//Go back and set ID_FIRST_MSG and ID_LAST_MSG in the topics table
    
@mysql_query("
         UPDATE smf_topics
            SET ID_FIRST_MSG = '
$messageid',
            ID_LAST_MSG = '
$messageid'
            WHERE ID_TOPIC = '
$topic'
      "
,$obj_db) or die(mysql_error());
//Increment total posts for board
    
@mysql_query("
         UPDATE smf_boards
            SET numPosts = numPosts + 1,
            numTopics = numTopics + 1
            WHERE ID_BOARD = '
$boardid'
      "
,$obj_db) or die(mysql_error());
//Increment Total Messages
    
@mysql_query("
         UPDATE smf_settings
            SET value = value + 1
            WHERE variable = 'totalMessages'
      "
,$obj_db) or die(mysql_error());
//Increment Total Topics
    
@mysql_query("
         UPDATE smf_settings
            SET value = value + 1
            WHERE variable = 'totalTopics'
      "
,$obj_db) or die(mysql_error());
// Increment post count for user record
    
@mysql_query("
                        UPDATE smf_members
                        SET posts = posts + 1
                                WHERE ID_MEMBER = '
$userid'
                "
,$obj_db) or die(mysql_error());
        }
    }

if (
$obj_db) {
    @
mysql_close($obj_db);
}
?>



let me know if this works for ya!
Don't tell me to get into shape...I have a shape...It is round!


Xarcell

Same as before.

When I run the news.php file I don't get any errors, but nothing shows up in the forums...

TechnoDragon

what is the link to your board you are trying to post in?
Don't tell me to get into shape...I have a shape...It is round!


Xarcell

www.xboxnarc.com

the "Xbox.com" board...

www.xboxnarc.com/injector/news.php

TechnoDragon

Try this...I got it to work on my forum...just make sure you have the top four items correct...

<?php
//
// SMF RSS Injector by Jerry Bell - [email protected]
// Based on the Joomla RSS import script by Max Soukhomlinov, [email protected]
// 
// This script requires XML_RSS and PHP Pear Libraries
// 
//
// This script is quick and dirty. Please remember to abide by the RSS content providers' terms of use.  

/** the PEAR XML_RSS object/class is required */
require 'RSS.php';

/** DATABASE Configuration */
define("DB_HOSTNAME","360.xboxnarc.com"); //Insert your DB server name here
define("DB_USERNAME","narcmaster"); //DB username here
define("DB_PASSWD","********"); // DB password here
define("DB_DATABASE","gamemod"); //DB name here
$userid 5//Set this to the SMF userid you want the messages posted from
$boardid 25;//Set this to the id of the board you want to post the messages in

/** pull list of remote RSS feeds, via a remote RSS feed. */
$rss_feed = & new XML_RSS('http://rss.gamespot.com/misc/rss/gamespot_updates_xbox_360.xml'); //Insert your URL here
//$rss_feed = & new XML_RSS(''); //Used this for testing with local file, a bit quicker
// Function for shortening articles based on maximum length
function str_stop($string$max_length){
   if (
strlen($string) > $max_length){
       
$string substr($string0$max_length);
       
$pos strrpos($string" ");
       if(
$pos === false) {return substr($string0$max_length)."...";}
       return 
substr($string0$pos)."...";
   }else{return 
$string;}
}
/** create the database connection object */
$obj_db = @mysql_connect(DB_HOSTNAME,DB_USERNAME,DB_PASSWD) or die (mysql_error());

/** select the intended database */
@mysql_select_db(DB_DATABASE,$obj_db) or die (mysql_error());

$rss_feed->parse();

$num_articles=0//Variable used to count number of new articles, displayed in an email below

    // Here we make sure that feed articles do not already exist in DB
    // this uses title names, make sure to use the same title formatting here as you will use further down
    // state = 1 not trashed
    
foreach ($rss_feed->getItems() as $item) {
        
$obj_query = @mysql_query("
            SELECT
                COUNT(ID_MSG) AS link_match
            FROM
                smf_messages
            WHERE
                subject = '"
str_stop(addslashes($item['title']),100) ."'
        "
,$obj_db) or die(mysql_error());

        
$int_count = @mysql_fetch_assoc($obj_query) or die(mysql_error());

        
mysql_free_result($obj_query);

        if (
$int_count['link_match'] == 0) {

    
$num_articles $num_articles +1;
/**
 * REFORMATTING CODE
 **/
// In my experience you have to play with the definitions from different RSS feeds - some rss feeds call fields different things.  
$titletext str_stop(addslashes($item['title']),100);
// This adds an html link at to the original article at the very bottom of the post.
$maintext addslashes($item['description']) . "<p><a href=\"" $item['link'] . "\">" $item['link'] . "</a>";
    @
mysql_query("
INSERT INTO smf_topics(
ID_BOARD,
ID_MEMBER_STARTED,
ID_MEMBER_UPDATED
) VALUES (
'
$boardid',
'
$userid',
'
$userid'
)
"
,$obj_db) or die(mysql_error());
$topic mysql_insert_id();
$postertime date('U');
//Insert the actual message
    
@mysql_query("
INSERT INTO smf_messages(
subject,
body,
  ID_MEMBER,
ID_BOARD,
ID_TOPIC,
posterTime
) VALUES (
'"
$titletext ."',
'"
$maintext ."',
'
$userid',
'
$boardid',
'
$topic',
'
$postertime'
)
"
,$obj_db) or die(mysql_error());
$messageid mysql_insert_id();
//Go back and set ID_FIRST_MSG and ID_LAST_MSG in the topics table
    
@mysql_query("
UPDATE smf_topics
SET ID_FIRST_MSG = '
$messageid', 
ID_LAST_MSG = '
$messageid'
WHERE ID_TOPIC = '
$topic'
"
,$obj_db) or die(mysql_error());
//Increment total posts for board
    
@mysql_query("
UPDATE smf_boards
SET numPosts = numPosts + 1, 
numTopics = numTopics + 1
WHERE ID_BOARD = '
$boardid'
"
,$obj_db) or die(mysql_error());
//Increment Total Messages
    
@mysql_query("
UPDATE smf_settings
SET value = value + 1
WHERE variable = 'totalMessages'
"
,$obj_db) or die(mysql_error());
//Increment Total Topics
    
@mysql_query("
UPDATE smf_settings
SET value = value + 1
WHERE variable = 'totalTopics'
"
,$obj_db) or die(mysql_error());
// Increment post count for user record
    
@mysql_query("
                        UPDATE smf_members
                        SET posts = posts + 1
                                WHERE ID_MEMBER = '
$userid'
                "
,$obj_db) or die(mysql_error());
        } 
    }

if (
$obj_db) {
    @
mysql_close($obj_db);
}
?>
Don't tell me to get into shape...I have a shape...It is round!


Xarcell


TechnoDragon

hmmmm....Are you sure that the details at the top are correct?  All i did with that posted info was put my details in there in it's place (plus change the userid and board number) and it worked flawlessly.

try using a different board and/or userid just to test it out
Don't tell me to get into shape...I have a shape...It is round!


L.G.S

Quote from: technodragon73 on March 22, 2006, 05:08:40 PM
Quote from: L.G.S on March 22, 2006, 11:58:48 AM
Quote from: technodragon73 on March 21, 2006, 08:38:29 PM
post a link to the site so i can take a look

http://www.tactical-illusion.com/board

should be going into the sport area.

do you have a test account?

that way i can view the booard and topics.

username: test
pass: test
FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


TechnoDragon

Quote from: L.G.S on March 23, 2006, 12:30:55 PM
Quote from: technodragon73 on March 22, 2006, 05:08:40 PM
Quote from: L.G.S on March 22, 2006, 11:58:48 AM
Quote from: technodragon73 on March 21, 2006, 08:38:29 PM
post a link to the site so i can take a look

http://www.tactical-illusion.com/board

should be going into the sport area.
Did you try copying and pasting the last code update from this page?  Try that and put your info in there and let me know what happens.
do you have a test account?

that way i can view the booard and topics.

username: test
pass: test
Don't tell me to get into shape...I have a shape...It is round!


Advertisement: