You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feed-io is designed to read feeds across the internet and to publish your own. Its main class is FeedIo :
58
+
59
+
```php
60
+
<?php
61
+
// create a simple FeedIo instance
62
+
$feedIo = \FeedIo\Factory::create()->getFeedIo();
63
+
64
+
// read a feed
65
+
$result = $feedIo->read($url);
66
+
67
+
// get title
68
+
$feedTitle = $result->getFeed()->getTitle();
69
+
70
+
// iterate through items
71
+
foreach( $result->getFeed() as $item ) {
72
+
echo $item->getTitle();
73
+
}
74
+
75
+
```
76
+
77
+
## Next Update estimation
78
+
79
+
In order to save bandwidth, feed-io estimates the next time it will be relevant to read the feed and get new items from it.
80
+
81
+
```php
82
+
<?php
83
+
$nextUpdate = $result->getNextUpdate();
84
+
echo "computed next update: {$nextUpdate->format(\DATE_ATOM)}";
85
+
86
+
// you may need to access the statistics
87
+
$updateStats = $result->getUpdateStats();
88
+
echo "average interval in seconds: {$updateStats->getAverageInterval()}";
89
+
```
90
+
91
+
92
+
feed-io calculates the next update time by first detecting if the feed was active in the last 7 days and if not we consider it as sleepy. The next update date for a sleepy feed is set to the next day at the same time. If the feed isn't sleepy we use the average interval and the median interval by adding those intervals to the feed's last modified date and compare the result to the current time. If the result is in the future, then it's returned as the next update time. If none of them are in the future, we considered the feed will be updated quite soon, so the next update time is one hour later from the moment of the calculation. Please note: the fixed delays for sleepy and closed to be updated feeds can be set through Result::getNextUpdate() arguments, see Result for more details.
0 commit comments