mcstutterfish / fbia-rss
Facebook Instant Articles RSS Builder(包含Laravel 4 Service Provider)
0.1.11
2016-07-27 19:37 UTC
Requires
- php: >=5.3.0
- illuminate/support: 4.*|5.*
This package is not auto-updated.
Last update: 2024-09-14 18:26:26 UTC
README
Laravel 4的Facebook Instant Articles RSS构建器
安装
将mcstutterfish/fbia-rss
添加到composer.json
。
"mcstutterfish/fbia-rss": "~1.0"
运行composer update
以获取FBIARss的最新版本。
现在打开app/config/app.php
并将服务提供者添加到您的providers
数组中。
'providers' => array(
'FBIARss\FBIARssServiceProvider',
)
现在添加别名。
'aliases' => array(
'FBIARss' => 'FBIARss\FBIARssFacade',
)
用法
返回源
Route::get('/', function()
{
$feed = FBIARss::feed('2.0', 'UTF-8');
$feed->channel(array('title' => 'Channel\'s title', 'description' => 'Channel\'s description', 'link' => 'http://www.test.com/'));
for ($i=1; $i<=5; $i++){
$feed->item(array('title' => 'Item '.$i, 'description|cdata' => 'Description '.$i, 'link' => 'http://www.test.com/article-'.$i));
}
return Response::make($feed, 200, array('Content-Type' => 'text/xml'));
});
保存源
Route::get('/', function()
{
$feed = FBIARss::feed('2.0', 'UTF-8');
$feed->channel(array('title' => 'Channel\'s title', 'description' => 'Channel\'s description', 'link' => 'http://www.test.com/'));
for ($i=1; $i<=5; $i++){
$feed->item(array('title' => 'Item '.$i, 'description|cdata' => 'Description '.$i, 'link' => 'http://www.test.com/article-'.$i));
}
$feed->save('test.xml');
});