RSS Injector available

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

Previous topic - Next topic

L.G.S

I have tried the code yes, and nothing. Worked once now it's dead.
FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


TechnoDragon

it worked once?

Well it may not be working not because it is broken, but because there are no new news coming rom that feed...the php file is designed to test against what has already been posted and skip it if it thinks it is already there...try a different feed and see what happens
Don't tell me to get into shape...I have a shape...It is round!


Xarcell

You have to run the new.php to show feeds each time, unless you set up a cron job to run it for you automactically.

TechnoDragon

Quote from: Xarcell on March 24, 2006, 09:58:14 PM
You have to run the new.php to show feeds each time, unless you set up a cron job to run it for you automactically.

Did you get your to work?  I hadn't heard from you in awhile.  Just wondering.
Don't tell me to get into shape...I have a shape...It is round!


L.G.S

Quote from: Xarcell on March 24, 2006, 09:58:14 PM
You have to run the new.php to show feeds each time, unless you set up a cron job to run it for you automactically.

Yes I know that, I did read the posts.

thanks for the help everyone, although I think I will not use this
FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


L.G.S

Scratch that last comment, I have figured it out.

Although I have one problem, when I click MARK READ in recent posts they never go away :(
FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


TechnoDragon

ok, that is a very fixable problem.  Go into your admin panel, click forum maitenence, click recount forum statistics.  Once that it complete, click fixes all errors and click yes...voila...problems go away!

It is a bug that I cannot figure out how to fix.  (not that familiar with coding)
Don't tell me to get into shape...I have a shape...It is round!


L.G.S

Nope, they are all still there lol.

Also how do I make them appear on the forum index as new posts? in the 'last post' are it always says NA
FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


TechnoDragon

Quote from: L.G.S on March 25, 2006, 11:57:06 AM
Nope, they are all still there lol.

Also how do I make them appear on the forum index as new posts? in the 'last post' are it always says NA

That is another problem i have been trying to get fixed....I did not write the original coding for this...jsut figured out how to get it to work.  Anyone that can answer that question of how to make them show up as "new" would be greatly appreciated...as far as NA...it is because the injector uses the member ID rather than the name...I could not figure out how to get it to do that either.
Don't tell me to get into shape...I have a shape...It is round!


L.G.S

ok thanks,

I guess I will have to wait until someone picks up on this.
FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


TechnoDragon

Quote from: L.G.S on March 25, 2006, 02:23:21 PM
ok thanks,

I guess I will have to wait until someone picks up on this.

You can see how it works at my site...I have three different boards right now using it:

http://forum.technodragon.net/index.php?board=56.0
http://forum.technodragon.net/index.php?board=57.0
http://forum.technodragon.net/index.php?board=58.0

(Actually I have more, but I figure these are enough to see what works)
Don't tell me to get into shape...I have a shape...It is round!


L.G.S

FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


Xarcell

Damnit, wish mine would work...

TechnoDragon

Quote from: L.G.S on March 25, 2006, 07:10:07 PM
I do not know what you are trying to show me but mine are here:

http://www.tactical-illusion.com/board/index.php?board=167.0

So basically you got yours working?  Except for the "new" issue?
Quote from: Xarcell on March 25, 2006, 08:50:47 PM
Damnit, wish mine would work...

Yours is still not working at all?
Don't tell me to get into shape...I have a shape...It is round!


L.G.S

Yes they are working except for the part where they dont show as new.

I'm not too good with code, where would I increase the post characters?
FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


TechnoDragon

Quote from: L.G.S on March 26, 2006, 05:32:01 AM
Yes they are working except for the part where they dont show as new.

I'm not too good with code, where would I increase the post characters?

The post is entirely dependant on what the news feed provides...it doesn't pull any more info than the fedd gives...so if it only gives a link and title...that is all you get, but if it gives more (as some do) like an image, brief summary, and link then you get that instead.
Don't tell me to get into shape...I have a shape...It is round!


L.G.S

FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


Xarcell

@ L.G.S

At first you where having the same problem I was. Now yours is work. What did you do to get it to work?

Can I please get a copy of the news.php you used? Just remove your password and such.

Thanks,

-Xarcell


L.G.S

I now have a file for each news type, so here is my world news file:

<?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","localhost"); //Insert your DB server name here
define("DB_USERNAME",""); //DB username here
define("DB_PASSWD",""); // DB password here
define("DB_DATABASE",""); //DB name here
$userid 475//Set this to the SMF userid you want the messages posted from
$boardid 170.0;//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://news.google.co.uk/nwshp?tab=wn&ned=uk&topic=w&output=rss'); //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
                smf2_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 smf2_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 smf2_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 smf2_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 smf2_boards
SET numPosts = numPosts + 1, 
numTopics = numTopics + 1
WHERE ID_BOARD = '
$boardid'
"
,$obj_db) or die(mysql_error());
//Increment Total Messages
    
@mysql_query("
UPDATE smf2_settings
SET value = value + 1
WHERE variable = 'totalMessages'
"
,$obj_db) or die(mysql_error());
//Increment Total Topics
    
@mysql_query("
UPDATE smf2_settings
SET value = value + 1
WHERE variable = 'totalTopics'
"
,$obj_db) or die(mysql_error());
// Increment post count for user record
    
@mysql_query("
                        UPDATE smf2_members
                        SET posts = posts + 1
                                WHERE ID_MEMBER = '
$userid'
                "
,$obj_db) or die(mysql_error());
        } 
    }

if (
$obj_db) {
    @
mysql_close($obj_db);
}
?>
FREE and LIVE World Cup + Premier League football streams:

www.gamesandgoals.com


TechnoDragon

I did exactly the same thing...every feed has a different file...now if I had enough CRON jobs to run them all!  LOL
Don't tell me to get into shape...I have a shape...It is round!


Advertisement: