forked from suin/php-rss-writer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsimple-feed.php
48 lines (41 loc) · 1.39 KB
/
simple-feed.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
use Suin\RSSWriter\Channel;
use Suin\RSSWriter\Feed;
use Suin\RSSWriter\Item;
// Load test target classes
spl_autoload_register(function ($c) {
@include_once strtr($c, '\\_', '//') . '.php';
});
set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__DIR__) . '/src');
$feed = new Feed();
$channel = new Channel();
$channel
->title('Channel Title')
->description('Channel Description')
->url('http://blog.example.com')
->language('en-US')
->copyright('Copyright 2012, Foo Bar')
->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
->lastBuildDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
->ttl(60)
->appendTo($feed);
// Blog item
$item = new Item();
$item
->title('Blog Entry Title')
->description('Blog body')
->contentEncoded('<div>Blog body</div>')
->url('http://blog.example.com/2012/08/21/blog-entry/')
->author('Hidehito Nozawa')
->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))
->guid('http://blog.example.com/2012/08/21/blog-entry/', true)
->appendTo($channel);
// Podcast item
$item = new Item();
$item
->title('Some Podcast Entry')
->description('<div>Podcast body</div>')
->url('http://podcast.example.com/2012/08/21/podcast-entry/')
->enclosure('http://podcast.example.com/2012/08/21/podcast.mp3', 4889, 'audio/mpeg')
->appendTo($channel);
echo $feed; // or echo $feed->render();