Jump to content

Load RSS Feeds (MarkupLoadRSS)


ryan

Recommended Posts

On 6/11/2018 at 4:39 AM, combicart said:

When a page is in the RSS feed and is already add to ProcessWire. Is there a way to find a page and update it's content through the API?

You already have part of the logic for this - now you just need the else. I would tend to flip the logic around the other way though...

if($p->id) {
    // $p is an existing page, so prepare it for saving new field values
    $p->of(false);
} else {
    // No existing page so create one
    $p = new Page();
    // ...
}
// Now set the field values of $p

 

On 6/11/2018 at 4:39 AM, combicart said:

When a page is not in the RSS feed anymore. Is there a way to delete all pages that are not in the RSS feed?

Keep track of the job ids in the RSS feed using an array. Then find any pages with job ids that are not in the array and delete them.

$job_ids = [];
foreach($rss as $item) {
    $job_ids[] = $item->id;
    // The rest of your code...
}

// Implode for use in selector string
$job_ids = implode('|', $job_ids);

// Find pages for deletion
$delete_pages = $pages->find("job_id!=$job_ids");
foreach($delete_pages as $delete_page) {
    $delete_page->delete();
}

 

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

I would like to import a description field including it's HTML markup. In the RSS feed the markup is included, however by default the markup is stripped by the RSS feed module.

Therefore i've used the option below to render the description including markup:

$rss->stripTags = false;

After adding this option, the values in the database are still escaped, e.g. like:

<h3 class="deprecated-h3">Description</h3>
<p>Description</p> 

Would it be possible to save  the description field directly into the database (including it's HTML markup)?

Link to comment
Share on other sites

  • 2 months later...
31 minutes ago, Robin S said:

I don't think that colon is supposed to be at the end - that URL leads to a 404. Looks the URL should be https://insidemodernism.co.uk/feed/

Not sure why it's showing that. This is my code which was working before it forced https (I changed http to https in the load).

$imRss = $modules->get('MarkupLoadRSS');
$imRss->limit = 1;
$imRss->cache = 3600;
$imRss->load("https://insidemodernism.co.uk/feed/");
bd($imRss);

 

Screen Shot 2018-08-22 at 23.13.19.png

Link to comment
Share on other sites

  • 2 months later...

I attempted just to do a standard PHP fetch for the RSS to check if it had any errors...

Warning: DOMDocument::load(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed in /www3/453/www.modernshows.com/web/test.php on line 16

Warning: DOMDocument::load(): Failed to enable crypto in /www3/453/www.modernshows.com/web/test.php on line 16

Warning: DOMDocument::load(https://insidemodernism.co.uk/feed/): failed to open stream: operation failed in /www3/453/www.modernshows.com/web/test.php on line 16

I can obviously turn this off with the following (which isn't ideal) but unsure how to fix properly especially for this module.

stream_context_set_default([
	'ssl' => [
		'verify_peer' => false,
		'verify_peer_name' => false
	]
]);

 

Link to comment
Share on other sites

  • 1 year later...

Sorry to bring this back up but I'm still having issues.

I looked at the module at how it's grabbing the feed and tested it in a Tracy console and it returned false...

$http = new WireHttp();
$xmlData = $http->get("https://insidemodernism.co.uk/feed/");
$rss = simplexml_load_string($xmlData);
bdb($rss);

Any further thoughts?

Link to comment
Share on other sites

  • 6 months later...

hello, so i am trying to make a website that collects some urls collect rss feeds from them a output them in my website, and preferably somehow output the stuff inside my website too, i am not sure how do do it i never worked with RSS but i found this RSS feed loader module, but not sure how to input any feed into it.

i am tryin to import for example this feed https://www.realwire.com/rss/?id=345&row=&view=Synopsis

so far i am not sure how to feed it into the module and somehow input title from that feed and some more options? in module setinggs examples are only like fixed titles descriptions etc.

how does this exacly work ?

Link to comment
Share on other sites

21 minutes ago, picarica said:

hello, so i am trying to make a website that collects some urls collect rss feeds from them a output them in my website, and preferably somehow output the stuff inside my website too, i am not sure how do do it i never worked with RSS but i found this RSS feed loader module, but not sure how to input any feed into it.

For the record I've merged your question to the Markup Load RSS support thread. The Modules/Plugins area of the support forum is dedicated to third party module support threads, one thread per module — please try to post your questions to the applicable thread if one exists. Thanks!

21 minutes ago, picarica said:

i am tryin to import for example this feed https://www.realwire.com/rss/?id=345&row=&view=Synopsis

so far i am not sure how to feed it into the module and somehow input title from that feed and some more options?

Here's one of the examples from the first post in this thread:

<?php

$rss = $modules->get("MarkupLoadRSS");

$rss->limit = 5;
$rss->cache = 0;
$rss->maxLength = 255;
$rss->dateFormat = 'm/d/Y H:i:s';

$rss->load("http://www.di.net/articles/rss/");

echo "<h2>{$rss->title}</h2>";
echo "<p>{$rss->description}</p>";
echo "<ul>";

foreach($rss as $item) {
    echo "<li>" . $item->title . "</li>";
}

echo "</ul>";

It seems to me that this example is doing pretty much exactly what you asked, i.e. it loads a feed using this module and then outputs the title of the "channel" element from the feed, as well as a list of found items. Please let me know if I misunderstood your question, though.

Link to comment
Share on other sites

1 hour ago, teppo said:

For the record I've merged your question to the Markup Load RSS support thread. The Modules/Plugins area of the support forum is dedicated to third party module support threads, one thread per module — please try to post your questions to the applicable thread if one exists. Thanks!

Here's one of the examples from the first post in this thread:


<?php

$rss = $modules->get("MarkupLoadRSS");

$rss->limit = 5;
$rss->cache = 0;
$rss->maxLength = 255;
$rss->dateFormat = 'm/d/Y H:i:s';

$rss->load("http://www.di.net/articles/rss/");

echo "<h2>{$rss->title}</h2>";
echo "<p>{$rss->description}</p>";
echo "<ul>";

foreach($rss as $item) {
    echo "<li>" . $item->title . "</li>";
}

echo "</ul>";

It seems to me that this example is doing pretty much exactly what you asked, i.e. it loads a feed using this module and then outputs the title of the "channel" element from the feed, as well as a list of found items. Please let me know if I misunderstood your question, though.

yes this looks promising i tired it but cannot seem to run it ? with your url it didnt worked, so i tried mine and so i got internal server error

 

Quote

2020-11-01 16:46:12    guest   http://localhost/blog/  Fatal Error:     Uncaught Error: Call to undefined method stdClass::load() in /var/www/rss/site/templates/blog.php:20 Stack trace: #0 /var/www/rss/wire/core/TemplateFile.php(318): require() #1 /var/www/rss/wire/core/Wire.php(394): ProcessWire\TemplateFile->___render() #2 /var/www/rss/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___render', Array) #3 /var/www/rss/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\TemplateFile), 'render', Array) #4 /var/www/rss/wire/modules/PageRender.module(536): ProcessWire\Wire->__call('render', Array) #5 /var/www/rss/wire/core/Wire.php(397): ProcessWire\PageRender->___renderPage(Object(ProcessWire\HookEvent)) #6 /var/www/rss/wire/core/WireHooks.php(823): ProcessWire\Wire->_callMethod('___renderPage', Array) #7 /var/www/rss/wire/core/Wire.php(465): ProcessWire\WireHooks->runHooks(Object(ProcessWire\PageRender), 'renderPage', Array) #8 /var/www/rss/wire/core/WireHooks.php(924): ProcessWire\Wire->__call('renderPage', Array) #9 /var/www/rss/wire/core/Wir (line 20 of /var/www/rss/site/templates/blog.php)

i tried urls

https://www.realwire.com/rss/feeds.asp

and https://www.realwire.com/rss/?id=345&row=&view=Synopsis

 

Link to comment
Share on other sites

yes this works really good, but how do i input pultiple urls? and make them sort by date published? i already did some simple markup to make it look good, only problem is that $item->pubDate returns default date (01/01/1970 01:00:00 ) not sure why ? https://www.realwire.com/rss/?id=175&row=&view=Synopsis

pub date is correct there yet on my site it is outputed wrongly

Link to comment
Share on other sites

QUESTION

how does cache of this module work ?

i wonder beacuse i will be using alot of RSS, and i would like to save them localy so that they would load and fetch and receck (for deleted articles) only once per day every night, i wonder how does the cache work ? does it deletes all the RSS everytime it times out ? or it rechecks existing and new RSS and only updates deleted ones and adds new ones, whats the logic behind it ?

Link to comment
Share on other sites

  • 2 months later...

Hello friends,

I have the following problem. I got an XML file that looks like this:

<?xml version="1.0" encoding="UTF-8" ?>
<EXAMPLE>
  <job>
    <jobTitle>A title</jobTitle>
  </job>
  <job>
	<jobTitle>A title</jobTitle>
  </job>
</EXAMPLE>

So, what is missing here is the usual opening <rss> tag right after <? xml
and we don’t have the usual <channel> and <item> tags. Okay.
So, MarkupLoadRSS can not read this file until I change the following line 221 in the MarkupLoadRSS.module from

foreach($rss->channel->item as $item) {

to this

foreach($rss->EXAMPLE->job as $item) {

to be in line with my .xml file and also add a opening and closing <rss> tag directly into the .xml file like this:

<?xml version="1.0" encoding="UTF-8" ?>
<rss version='2.0'>
  <EXAMPLE>
    <job>
      <jobTitle>A title</jobTitle>
    </job>
    <job>
      <jobTitle>A title</jobTitle>
    </job>
  </EXAMPLE>
</rss>

The problem is, later, I will not be able to change the XML file, it is generated by another site.
So I need to tell MarkupLoadRSS to ignore the <rss> opening and closing tags.
Does anybody know how this is possible?
I had a deeper look into the module but I don’t see where the <rss> tag is a interpreted.
Maybe someone can give me a clue, please?
Thank so much in advance,

Thomas

Link to comment
Share on other sites

Easy solution!
If you want load an XML file like this one:

<?xml version="1.0" encoding="UTF-8" ?>
  <EXAMPLE>
    <job>
      <jobTitle>A title 1</jobTitle>
      <company>Company 1</company>
    </job>
    <job>
      <jobTitle>A title</jobTitle>
      <company>Company 2</company>
    </job>
  </EXAMPLE>

you can skip <Example> directly and change line 221 in MarkupLoadRSS.module to:

foreach($rss->job as $item) {

And in your template file to can access the <jobTitle> with:

$rss = $modules->get("MarkupLoadRSS"); 
$rss->load("example.xml");

foreach($rss as $item) {
	echo $item->jobTitle; 
}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...