2amigos / efeed Goto Github PK
View Code? Open in Web Editor NEWFeed Writer Generator Extension (RSS 1.0, RSS 2.0, and ATOM 1.0)
Feed Writer Generator Extension (RSS 1.0, RSS 2.0, and ATOM 1.0)
Here is my code
// RSS 2.0 is the default type
$feed = new EFeed();
$feed->title= 'blah blah';
$feed->description = 'blah blah';
$feed->addChannelTag('language', 'en-us');
$feed->addChannelTag('pubDate', date(DATE_RSS, time()));
$feed->addChannelTag('link', 'http://baabaa.com' );
$jobs = Job::model()->findAll($criteria);
foreach($jobs as $job) {
if (empty($job)) continue;
$item = $feed->createNewItem();
$item->title = utf8_encode($job->job_title);
$item->link = Yii::app()->createAbsoluteUrl('job/view',array(
'id'=>$job->id));
$item->date = time();
$item->description = utf8_encode(GFunctions::truncate($job->description, 500) . '...');
$feed->addItem($item);
}
$feed->generateFeed();
Yii::app()->end();
I keep getting Exception: No feed items configured /protected/extensions/feed/EFeed.php 847, and I can not figure out what was wrong.
Could you tag a (production) release?
CHROME:
This XML file does not appear to have any style information associated with it
Yii::import('ext.feed.*');
$feed = new EFeed(EFeed::ATOM);
// IMPORTANT : No need to add id for feed or channel. It will be automatically created from link.
$feed->title = 'Testing the ATOM RSS EFeed class';
$feed->link = 'http://www.ramirezcobos.com';
$feed->addChannelTag('updated', date(DATE_ATOM, time()));
$feed->addChannelTag('author', array('name'=>'Antonio Ramirez Cobos'));
$item = $feed->createNewItem();
$item->title = 'The first Feed';
$item->link = 'http://www.ramirezcobos.com';
// we can also insert well formatted date strings
$item->date ='2010/24/12';
$item->description = 'Test of CDATA Encoded description <b>EFeed Extension</b>';
$feed->addItem($item);
$feed->generateFeed();
I've followed your example, and put this in My View
// RSS 2.0 is the default type
$feed = new EFeed();
$feed->title= 'Testing RSS 2.0 EFeed class';
$feed->description = 'This is test of creating a RSS 2.0 Feed';
$feed->setImage('Testing RSS 2.0 EFeed class','http://www.ramirezcobos.com/rss',
'http://www.yiiframework.com/forum/uploads/profile/photo-7106.jpg');
$feed->addChannelTag('language', 'en-us');
$feed->addChannelTag('pubDate', date(DATE_RSS, time()));
$feed->addChannelTag('link', 'http://www.ramirezcobos.com/rss' );
// * self reference
$feed->addChannelTag('atom:link','http://www.ramirezcobos.com/rss/');
$item = $feed->createNewItem();
$item->title = "first Feed";
$item->link = "http://www.yahoo.com";
$item->date = time();
$item->description = 'This is test of adding CDATA Encoded description <b>EFeed Extension</b>';
// this is just a test!!
$item->setEncloser('http://www.tester.com', '1283629', 'audio/mpeg');
$item->addTag('author', '[email protected] (Antonio Ramirez)');
$item->addTag('guid', 'http://www.ramirezcobos.com/',array('isPermaLink'=>'true'));
$feed->addItem($item);
$feed->generateFeed();
in my Controller, i have this
public function actionFeed()
{
Yii::import('site.common.extensions.feed.*');
$this->renderPartial('feed');
Yii::app()->end();
}
but on chrome i get this error
This page contains the following errors:
error on line 1 at column 6: XML declaration allowed only at the start of the document
Below is a rendering of the page up to the first error.
and on mozilla i get this
XML Parsing Error: XML or text declaration not at start of entity
Location: http://localhost/dev/frontend/www/abc/bla/feed/
Line Number 1, Column 2: <?xml version="1.0" encoding="UTF-8"?>
-^
Any idea how to fix this?
Hello, in your example you write:
$feed->addChannelTag('atom:link','http://www.ramirezcobos.com/rss/');
which produces an xml parsing error because the atom namespace isn't set.
I've compared it with wordpress and their rss2.0 always has the atom namespace set.
So I would fix it by adding:
"xmlns:atom"=>"http://www.w3.org/2005/Atom",
into Efeed.php line 315
Thanks for your work, your extension was easy to implement and use :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.