Jump to content

[SOLVED] Parser just wont work heeeelp...


dirkobrien56

Recommended Posts

OK maybe someone can check what im doing wrong

<?php

//#### Parser

function rss_parser($feedurl,$notmore)

{
include "inc/config.php";

    //get the simplepie library
    require_once('simplepie.inc');

    $dahtmlheader ="Content-Type: text/html\r\nContent-Transfer-Encoding: 8bit\r\n";

    //grab the feed
    $feed = new SimplePie();
    //enable caching
    $feed->enable_cache(false);
    //init the process
    $feed->init();
 //let simplepie handle the content type (atom, RSS...)
    $feed->handle_content_type();

    $i=0;

    if ($feed->error)
    	{
    	echo $feed->error;
	};


        $feedurlcheck = preg_replace("/[^0-9a-zA-Z]/","",$feedurl);
        if (strlen($feedurl) > 50) {$feedurlcheck = substr($feedurlcheck, 0, 50);};

        foreach ($feed->get_items(0, 1) as $item)

           {
              if($notmore < $i +1){break;};

              $title = $item->get_title();
              $description = $item->get_content();
		  $url = $item->get_link();


			if(file_exists("save/".$feedurlcheck.".txt"))

				{

				$lastpost = file_get_contents("save/".$feedurlcheck.".txt");
				if($lastpost == $title){break;};

				};

                      echo $output;
			      echo "<div class='topicheader'><h3>".$title."</h3></div>";
			      echo "<div class='topicbody'>".$url."<div class='clear'></div></div>";


			      if($i == 0)

				 {

				   $newlastpostitle = $title;

				 };

			$i++;

		         };

	              if($lastpost != $title)

		        {

		          $fh = fopen("save/".$feedurlcheck.".txt", "w");
		          fputs($fh, $newlastpostitle);
		          fclose($fh);

		};

}
?>

Link to comment
https://forums.phpfreaks.com/topic/176449-solved-parser-just-wont-work-heeeelp/
Share on other sites

Unless you bother to state exactly what problem you are having and what you see in front of you when you try your code, no one can directly help you.

 

We are not standing next to you. If you aren't, can't, or won't provide relevant information in your post, you likely won't get a relevant reply. For all we know, you are not even calling that function in any of your main code.

Oh yeah sorry ok im trying to get feed of my blog to bookmark my posts just cant get it to work im not very pro with php so its hard to explain to you i can post entire script if needed

 

index.php

 

<?php


//error_reporting(0);
include "inc/config.php";
require_once('inc/testparser.php');
require_once('inc/loginclass.php');


//#### Rss feeds

$i=0;
$handle = fopen ("rss_feeds.csv","r");

while ( ($data = fgetcsv ($handle, 1000, ",")) !== FALSE )

	{

$randblog = rand(0, 100);

if($percblog < $randblog)
	{
	continue 1;
	};

$feedurl = $data[0];
$notmore = $data[1];

$i++;

rss_parser($feedurl,$notmore);

}

fclose ($handle);

echo "<div class='status' style='margin-top:90px'>Bookmarker checked ".$i." feed for updates</div>";

?>

 

 

config.php

 

<?php

$xml = simplexml_load_file('inc/config.xml');

// Bookmarker will random post per action
$percblog = $xml->options->percblog;


?>

 

config.xml

 

<?xml version="1.0" encoding="utf-8"?><lfm status="ok"><options><percblog>100</percblog></options></lfm>

 

rss_feeds.csv

 

"feedurll",1

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.