simplepie

Use simplepie with composer

倖福魔咒の 提交于 2020-06-01 04:47:06
问题 I am using PHP 7.3.5 and Composer version 1.8.5 and would like to use "simplepie/simplepie": "^1.5" to get data from an rss feed. When running the below script I get the error: Fatal error: Uncaught Error: Class 'SimplePie\SimplePie' not found <?php require 'vendor/autoload.php'; use SimplePie\SimplePie; $url = 'https://www.reddit.com/r/worldnews/top.rss?t=day'; $feed = new SimplePie(); $feed->set_feed_url($url); $feed->init(); How to correctly use simplepie with composer? 回答1: You can try:

Renew WordPress Feed Cache in the Background

*爱你&永不变心* 提交于 2020-01-16 19:41:13
问题 I'm looking for a way to refresh feed caches in the background. To demonstrate the issue I'm facing with, the below code would help. It renews the cache in every 30 seconds when the page is accessed and loaded. Since it has lots of urls to fetch at once, it gets really slow when the cache needs to be rebuild. $urls = array( 'http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&output=rss', 'http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&topic=w&output=rss', 'http://news.google.com/news

Renew WordPress Feed Cache in the Background

安稳与你 提交于 2020-01-16 19:40:48
问题 I'm looking for a way to refresh feed caches in the background. To demonstrate the issue I'm facing with, the below code would help. It renews the cache in every 30 seconds when the page is accessed and loaded. Since it has lots of urls to fetch at once, it gets really slow when the cache needs to be rebuild. $urls = array( 'http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&output=rss', 'http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&topic=w&output=rss', 'http://news.google.com/news

Renew WordPress Feed Cache in the Background

不羁的心 提交于 2020-01-16 19:39:16
问题 I'm looking for a way to refresh feed caches in the background. To demonstrate the issue I'm facing with, the below code would help. It renews the cache in every 30 seconds when the page is accessed and loaded. Since it has lots of urls to fetch at once, it gets really slow when the cache needs to be rebuild. $urls = array( 'http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&output=rss', 'http://news.google.com/news?pz=1&cf=all&ned=us&hl=en&topic=w&output=rss', 'http://news.google.com/news

<![CDATA in SimplePie

。_饼干妹妹 提交于 2020-01-06 04:09:42
问题 I've been working on some RSS Scrapper that parses data from multiple sources. That said, all this sources have their own implementation of the description of the RSS. One in particular, uses CDATA tags to write the description on like, for example <![CDATA[ <p align=justify><font face="verdana, arial, helvetica, sans-serif" size=1> <font color=#004080></font> SOME TEXT GOES HERE </font></p> ]]> However if I try to get the item description with SimplePie I get this output <div><p align=

<![CDATA in SimplePie

社会主义新天地 提交于 2020-01-06 04:08:10
问题 I've been working on some RSS Scrapper that parses data from multiple sources. That said, all this sources have their own implementation of the description of the RSS. One in particular, uses CDATA tags to write the description on like, for example <![CDATA[ <p align=justify><font face="verdana, arial, helvetica, sans-serif" size=1> <font color=#004080></font> SOME TEXT GOES HERE </font></p> ]]> However if I try to get the item description with SimplePie I get this output <div><p align=

How to get DOCUMENT_ROOT to work on both localhost and web host?

怎甘沉沦 提交于 2019-12-31 02:53:11
问题 I have a WordPress plugin that I would like to work on localhost as well as in deployment without modification, but I can't seem to set the location for a directory using one statement. I would like to do this: $feed->set_cache_location($_SERVER['DOCUMENT_ROOT'] . '/wp-content/cache'); While that works on the web host. On localhost it produces this error: C:/xampp/htdocs/wp-content/cache/a547b8792c3144c98549be23ef1465e7.spc is not writeable On localhost, I need to set it to this to get it

PHP way of parsing HTML string

坚强是说给别人听的谎言 提交于 2019-12-30 19:26:43
问题 I have a php string that contains the below HTML I am retrieving from an RSS feed. I am using simple pie and cant find any other way of splitting these two datasets it gets from <description> . If anyone knows of a way in simple pie to select children that would be great. <div style="example"><div style="example"><img title="example" alt="example" src="example.jpg"/></div><div style="example">EXAMPLE TEXT</div></div> to: $image = '<img title="example" alt="example" src="example.jpg">';

SimplePie and get_item_tags attribute

隐身守侯 提交于 2019-12-25 06:39:33
问题 I'm using Simplepie to parse different RSS feeds, passing them to a Smarty template, and I need to return the attribute from each item line that in this example reads: NEWSX <source url="http://whatever.url/"><![CDATA[NEWSX]]></source> I have found the get_item_tags method will select the line and attribute having used the following: $newssource = $item->get_item_tags('','source'); Here is my problem. I don't know how to attach each source to an item when using the following code (so that

RSS Feed getting cut off

扶醉桌前 提交于 2019-12-25 03:11:39
问题 I'm trying to pull in an RSS feed into my PHP code. When I view the feed with Google Reader, I see several hundred items in the feed. However, when I pull it into my code, I'm only seeing 10. What is the reason for the difference and how can I pull in the full feed? 回答1: Since you don't show your code, it is impossible to say with certainty what is wrong. However, you tagged your question as a SimplePie question and SimplePie defaults to 10 items in some places. So, that's likely what is