title() публичный Метод

public title ( $title )
Пример #1
0
function generate_rss($posts)
{
    $feed = new Feed();
    $channel = new Channel();
    $channel->title(config('blog.title'))->description(config('blog.description'))->url(site_url())->appendTo($feed);
    foreach ($posts as $p) {
        $item = new Item();
        $item->title($p->title)->description($p->body)->url($p->url)->appendTo($channel);
    }
    echo $feed;
}
Пример #2
0
function generate_rss($posts)
{
    $feed = new Feed();
    $channel = new Channel();
    $channel->title('LBlog')->description('A very light weight blog.')->url('http://localhost:8000')->appendTo($feed);
    $item = new Item();
    foreach ($posts as $post) {
        $item->title($post->title)->description($post->body)->url($post->url)->appendTo($channel);
    }
    echo $feed;
}
Пример #3
0
 public function get()
 {
     $posts = Model::factory('Article')->where('status', '1')->order_by_desc('point')->limit(10)->find_many();
     $feed = new FeedFactory();
     $channel = new Channel();
     $channel->title(config('site.title'))->description(config('site.default_meta'))->url(Url::site())->appendTo($feed);
     foreach ($posts as $post) {
         $item = new Item();
         /** @var $post \Model\Article */
         $item->title($post->title)->description(Html::fromMarkdown($post->content))->url($post->permalink())->pubDate(strtotime($post->created_at))->appendTo($channel);
     }
     $this->data = substr($feed, 0, -1);
 }
Пример #4
0
 /**
  * Method to render the view.
  *
  * @return  string  The rendered view.
  *
  * @throws  \RuntimeException
  */
 public function render()
 {
     $this->prepareGlobals($this->getData());
     $this->prepareData($this->getData());
     $feed = new Feed();
     $channel = new Channel();
     $channel->title($this['blog']->title)->description($this['blog']->description)->url($this['uri']->get('base.full'))->appendTo($feed);
     foreach ($this['posts'] as $post) {
         $item = new Item();
         $item->title($post->title)->description($post->introtext)->url($this['uri']->get('base.full') . ltrim($post->link, '/'))->appendTo($channel);
     }
     return $feed;
 }
Пример #5
0
 public function showAction(Post $postModel)
 {
     $posts = $postModel->getRecentlyPosts(1, 20);
     $feed = new Feed();
     $channel = new Channel();
     $channel->title('Aicode')->description('爱生活,爱代码')->url('http://aicode.cc')->lastBuildDate($posts['data'][0]['publish_date'])->appendTo($feed);
     foreach ($posts['data'] as $art) {
         $item = new Item();
         $item->title($art['title'])->description('<p><img src="' . $art['feature_img'] . '" /></p>' . (new \Parsedown())->parse($art['content']))->url('http://aicode.cc/article/' . $art['id'] . '.html')->pubDate($art['publish_date'])->guid('http://aicode.cc/article/' . $art['id'] . '.html')->appendTo($channel);
     }
     header('Content-Type:text/xml; charset=utf-8');
     return $feed->render();
 }
Пример #6
0
 private function renderRss($competitions)
 {
     $this->setIsAjaxRequest(true);
     $baseUrl = Yii::app()->request->getBaseUrl(true);
     $feed = new Feed();
     $channel = new Channel();
     $channel->title(Yii::t('common', 'Cubing China'))->description(Yii::t('common', Yii::app()->params->description))->url($baseUrl)->language(Yii::app()->language)->copyright('Copyright ' . date('Y') . ', Cubing China')->pubDate(isset($competitions[0]) ? $competitions[0]->date : time())->lastBuildDate(time())->ttl(300)->appendTo($feed);
     foreach ($competitions as $competition) {
         $item = new Item();
         $item->title($competition->getAttributeValue('name'))->description($competition->getAttributeValue('information'))->url($baseUrl . CHtml::normalizeUrl($competition->getUrl('detail')))->pubDate($competition->date)->guid(CHtml::normalizeUrl($competition->getUrl('detail')), true)->appendTo($channel);
     }
     header('Content-Type:application/xml');
     echo $feed;
 }
Пример #7
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($type)
 {
     $feedData = $this->feed->where('slug', $type)->firstOrFail();
     $model = $feedData->model;
     $entities = $model::getFeedItems();
     $feed = new Feed();
     $channel = new Channel();
     $channel->title($feedData->title)->description($feedData->description)->url($feedData->url)->language($feedData->language)->copyright($feedData->copyright)->ttl($feedData->ttl)->appendTo($feed);
     foreach ($entities as $entity) {
         $item = new Item();
         $item->title($entity->itemTitle())->description($entity->itemDescription())->contentEncoded($entity->itemContent())->url($entity->itemUrl())->guid($entity->itemUrl(), true)->pubDate($entity->itemPubDate())->appendTo($channel);
     }
     return $feed;
 }
Пример #8
0
 public function index()
 {
     $parsedown = new \ParsedownExtra();
     $config = Configuration::find(1);
     $posts = Post::published()->orderBy('published_at', 'desc')->get();
     $feed = new Feed();
     $channel = new Channel();
     $channel->title($config->blog_title)->description($config->blog_description)->url(url('/'))->appendTo($feed);
     foreach ($posts as $post) {
         $item = new Item();
         $item->title($post->title)->description($parsedown->parse($post->content))->url(url("/articles/{$post->slug}"))->guid(url("/articles/{$post->slug}"), true)->appendTo($channel);
     }
     return response($feed)->header('Content-Type', 'application/rss+xml');
 }
Пример #9
0
 /**
  * Return a string with the feed data
  * 
  * @return string
  */
 protected function buildRssData()
 {
     $now = Carbon::now();
     $feed = new Feed();
     $channel = new Channel();
     $channel->title(config('blog.title'))->description(config('blog.description'))->url(url())->language('en')->copyright('Copyright ' . config('blog.author'))->lastBuildDate($now->timestamp)->appendTo($feed);
     $posts = Post::where('published_at', '<=', $now)->where('is_draft', 0)->orderBy('published_at', 'desc')->take(config('blog.rss_size'))->get();
     foreach ($posts as $post) {
         $item = new Item();
         $item->title($post->title)->description($post->subtitle)->url($post->url())->pubDate($post->published_at->timestamp)->guid($post->url(), true)->appendTo($channel);
     }
     $feed = (string) $feed;
     $feed = str_replace('<rss version="2.0">', '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">', $feed);
     $feed = str_replace('<channel>', '<channel' . "\n" . '    <atom:link href="' . url('/rss') . '" rel="self" type="application/rss+xml" />', $feed);
     return $feed;
 }
Пример #10
0
 /**
  * Return a string with the feed data
  *
  * @return string
  */
 protected function buildRssData()
 {
     $now = Carbon::now();
     $feed = new Feed();
     $channel = new Channel();
     $channel->title(config('blog.title'))->description(config('blog.description'))->url(url())->language('en')->copyright('Copyright (c) ' . config('blog.author'))->lastBuildDate($now->timestamp)->appendTo($feed);
     $articles = Article::where('published_date', '<=', $now)->orderBy('published_date', 'desc')->take(config('blog.rss_size'))->get();
     foreach ($articles as $article) {
         $item = new Item();
         $item->title($article->title)->tumnail_url($article->thumnail_url)->url($article->url())->pubDate($article->published_date->timestamp)->guid($article->url(), true)->appendTo($channel);
     }
     $feed = (string) $feed;
     // Replace a couple items to make the feed more compliant
     $feed = str_replace('<rss version="2.0">', '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">', $feed);
     $feed = str_replace('<channel>', '<channel>' . "\n" . '    <atom:link href="' . url('/rss') . '" rel="self" type="application/rss+xml" />', $feed);
     return $feed;
 }
Пример #11
0
    /**
     * Return a string with the feed data
     *
     * @return string
     */
    protected function buildRssData($objs, $type, $hash)
    {
        $now = \Carbon\Carbon::now();
        $feed = new Feed();
        $channel = new Channel();
        $channel->title(Config::get('site.name'))->description(Config::get('site.description'))->url($_ENV['SITE_URL'])->language('ht')->copyright('&copy; 2012 - ' . date('Y') . ' ' . Config::get('site.name') . ', Tout Dwa Rezève.')->lastBuildDate($now->timestamp)->appendTo($feed);
        foreach ($objs as $obj) {
            $item = new Item();
            $title = "#Nouvo{$hash} {$obj->name} #{$obj->category->slug} via @TKPMizik | @TiKwenPam";
            $item->title($title)->description($obj->description)->url(url("/{$type}/{$obj->id}"))->pubDate($obj->created_at->timestamp)->guid(url("/{$type}/{$obj->id}"), true)->appendTo($channel);
        }
        $feed = (string) $feed;
        // Replace a couple items to make the feed more compliant
        $feed = str_replace('<rss version="2.0">', '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">', $feed);
        $feed = str_replace('<channel>', '<channel>
			<atom:link href="' . url($_ENV['SITE_URL'] . "/{$type}/feed") . '" rel="self" type="application/rss+xml" />', $feed);
        return $feed;
    }
Пример #12
0
 protected function createRSSFeed()
 {
     $feed = new Feed();
     $channel = new Channel();
     $channel->title($this->kg['option']->getOption("channel.title"))->description($this->kg['option']->getOption("channel.description"))->url("https://youtube.com/user/" . $this->kg['config']['youtube_channel_username'])->appendTo($feed);
     $i = 0;
     foreach ($this->kg['video']->getDownloadedVideos() as $video) {
         if ($i >= 20) {
             break;
         }
         /** @var Video $video */
         $item = new Item();
         $item->title($video->getTitle())->description($video->getDescription())->url("https://www.youtube.com/watch?v=" . $video->getId())->enclosure($this->kg['config']['web_url'] . "/media/" . $video->getId() . ".mp3", filesize($this->kg['web_dir'] . "/media/" . $video->getId() . ".mp3"), 'audio/mpeg')->appendTo($channel);
         $i++;
     }
     $rssPath = $this->kg['web_dir'] . "/podcast.rss";
     file_put_contents($rssPath, $feed, LOCK_EX);
     $this->kg['monolog']->addDebug(sprintf("Rendered %s", $rssPath));
 }
Пример #13
0
 private function assembleFeed()
 {
     $feed = new Feed();
     $channel = new Channel();
     $posts = (new Post())->whereNotNull('published_at')->orderBy('published_at', 'DESC')->take(25)->get();
     $lastBuildDate = null;
     if (!$posts->isEmpty()) {
         $lastBuildDate = $posts->first()->published_at->timestamp;
     }
     $channel->title(config('genealabs-laravel-weblog.title'))->description(config('genealabs-laravel-weblog.title'))->url(url(config('genealabs-laravel-weblog.rss-route-name')))->language('en')->copyright(config('genealabs-laravel-weblog.copyright-notice'))->lastBuildDate($lastBuildDate)->appendTo($feed);
     foreach ($posts as $post) {
         $item = new Item();
         $item->title($post->title)->description($post->excerpt)->contentEncoded($post->content)->url($post->slug)->author($post->author->name)->pubDate($post->published_at->timestamp)->guid($post->slug, true)->appendTo($channel);
     }
     $feed = $feed->render();
     $feed = str_replace('<rss version="2.0">', '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">', $feed);
     $feed = str_replace('<channel>', '<channel>' . "\n" . '    <atom:link href="' . url(config('genealabs-laravel-weblog.rss-route-name')) . '" rel="self" type="application/rss+xml" />', $feed);
     return $feed;
 }
Пример #14
0
 public function buildRssFeed()
 {
     $now = Carbon::now();
     $feed = new Feed();
     $channel = new Channel();
     $channel->title(config('settings.app_name_' . config('app.locale')))->description("Le club Université Nantes Aviron est LE club d'aviron des étudiants nantais,\n            mais demeure ouvert à tous les publics et tous les types de pratiques.")->url(route('home'))->language('fr')->copyright('Copyright (c) ' . config('settings.app_name_' . config('app.locale')))->lastBuildDate($now->timestamp)->appendTo($feed);
     $news_list = $this->model->where('released_at', '<=', $now)->where('active', true)->orderBy('released_at', 'desc')->take(20)->get();
     foreach ($news_list as $news) {
         $item = new Item();
         // we parse the markdown content
         $parsedown = new Parsedown();
         $news->content = isset($news->content) ? $parsedown->text($news->content) : null;
         $item->title($news->title)->description(str_limit(strip_tags($news->content), 250))->url(route('news.show', ['id' => $news->id, 'key' => $news->key]))->pubDate(Carbon::createFromFormat('Y-m-d H:i:s', $news->released_at)->timestamp)->guid(route('news.show', ['id' => $news->id, 'key' => $news->key]), true)->appendTo($channel);
     }
     $feed = (string) $feed;
     // replace a couple items to make the feed more compliant
     $feed = str_replace('<rss version="2.0">', '<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">', $feed);
     $feed = str_replace('<channel>', '<channel>' . "\n" . '    <atom:link href="' . url('/rss') . '" rel="self" type="application/rss+xml" />', $feed);
     return $feed;
 }
    $token = $app->request()->params('token');
    $url = $prismic->get_api()->previewSession($token, $prismic->linkResolver, '/');
    $app->setCookie(Prismic\PREVIEW_COOKIE, $token, time() + 1800, '/', null, false, false);
    $app->response->redirect($url ? $url : '/', 301);
});
// RSS Feed,
// using the Suin RSS Writer library
$app->get('/feed', function () use($app, $prismic) {
    $blogUrl = $app->request()->getUrl();
    $posts = $prismic->get_posts(current_page($app))->getResults();
    $feed = new Feed();
    $channel = new Channel();
    $channel->title($prismic->config('site.title'))->description($prismic->config('site.description'))->url($blogUrl)->appendTo($feed);
    foreach ($posts as $post) {
        $item = new Item();
        $item->title($post->getText('post.title'))->description($post->getHtml('post.body', $prismic->linkResolver))->url($blogUrl . $prismic->linkResolver->resolveDocument($post))->pubDate($post->getDate('post.date')->asEpoch())->appendTo($channel);
    }
    echo $feed;
});
// --- DISQUS
$app->post('/disqus/threads/create', function () use($app, $prismic) {
    $title = $app->request->post('title');
    $identifier = $app->request->post('identifier');
    $apiKey = $prismic->config('disqus.apikey');
    $apiSecret = $prismic->config('disqus.apisecret');
    $accessToken = $prismic->config('disqus.accesstoken');
    $forum = $prismic->config('disqus.forum');
    if ($apiKey && $apiSecret && $accessToken && $forum) {
        $httpClient = \Prismic\Api::defaultHttpAdapter();
        $data = array('api_key' => $apiKey, 'api_secret' => $apiSecret, 'access_token' => $accessToken, 'forum' => $forum, 'title' => $title, 'identifier' => $identifier);
        $app->response->headers->set('Content-Type', 'application/json');
Пример #16
0
<?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)->pubsubhubbub('http://example.com/feed.xml', 'http://pubsubhubbub.appspot.com')->appendTo($feed);
// Blog item
$item = new Item();
$item->title('Blog Entry Title')->description('<div>Blog body</div>')->contentEncoded('<div>Blog body</div>')->url('http://blog.example.com/2012/08/21/blog-entry/')->author('John Smith')->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))->guid('http://blog.example.com/2012/08/21/blog-entry/', true)->preferCdata(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();
Пример #17
0
 /**
  * prepare feed
  */
 private function prepareRss($articleList)
 {
     $feed = new Feed();
     $channel = new Channel();
     $time = strtotime(date('Y-m-d'));
     $copyrightYear = date('Y');
     $channel->title("Blog Rss")->description("Blog Rss")->url(config('sys.sys_blog_domain'))->language('zh-CN')->copyright('Copyright ' . $copyrightYear . ', Jiang')->pubDate($time)->lastBuildDate($time)->ttl(3600 * 24)->appendTo($feed);
     foreach ($articleList as $key => $value) {
         $item = new Item();
         $item->title($value['title'])->description($value['content'])->url(route('blog.index.detail', ['id' => $value['id']]))->pubDate($value['write_time'])->guid(route('blog.index.detail', ['id' => $value['id']]), true)->appendTo($channel);
     }
     return $feed->render();
 }
Пример #18
0
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 *
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
require_once "../lib/base.php";
use Symfony\Component\HttpFoundation\Response as HTTPResponse;
use Suin\RSSWriter\Feed as RSSFeed;
use Suin\RSSWriter\Channel as RSSChannel;
use Suin\RSSWriter\Item as RSSItem;
$gl3Path = \Mesamatrix::path(\Mesamatrix::$config->getValue("info", "xml_file"));
$xml = simplexml_load_file($gl3Path);
if (!$xml) {
    \Mesamatrix::$logger->critical("Can't read " . $gl3Path);
    exit;
}
$baseUrl = \Mesamatrix::$request->getSchemeAndHttpHost() . \Mesamatrix::$request->getBasePath();
// prepare RSS
$rss = new RSSFeed();
$channel = new RSSChannel();
$channel->title(\Mesamatrix::$config->getValue("info", "title"))->description(\Mesamatrix::$config->getValue("info", "description"))->url($baseUrl)->appendTo($rss);
$commitWeb = \Mesamatrix::$config->getValue("git", "mesa_web") . "/commit/" . \Mesamatrix::$config->getValue("git", "gl3") . "?id=";
foreach ($xml->commits->commit as $commit) {
    $item = new RSSItem();
    $item->title((string) $commit["subject"])->url($baseUrl . '?commit=' . $commit["hash"])->pubDate((int) $commit["timestamp"])->appendTo($channel);
}
// send response
$response = new HTTPResponse($rss, HTTPResponse::HTTP_OK, ['Content-Type' => 'text/xml']);
$response->prepare(\Mesamatrix::$request);
$response->send();
Пример #19
0
$app->get('/', function (Request $request) use($app, $SERVER_ROOT, $SERVER_ROOT_SCRIPT) {
    $feed = new Feed();
    $channel = new Channel();
    $channel->title('Wurst update status');
    $channel->description("Uni-Hamburg server");
    $channel->url('http://zbh.uni-hamburg.de');
    $channel->appendTo($feed);
    $transformerCategory = new RecordToCategoryTransformer();
    $transformerTitle = new RecordToTitleTransformer($transformerCategory);
    $transformerDescription = new RecordToDescriptionTransformer($app['twig']);
    foreach ($app['wurst.history']->collection() as $id => $element) {
        $item = new Item();
        $item->author("wurst update");
        $item->url("http://{$SERVER_ROOT_SCRIPT}/details/{$id}");
        $item->pubDate($element->getDate());
        $item->title($transformerTitle->transform($element));
        $item->category($transformerCategory->transform($element));
        $item->description($transformerDescription->transform($element));
        $item->appendTo($channel);
    }
    return new Response($feed, 200);
});
/**
 * Method to show details for given record in rss stream
 *
 * @todo ids for all records are not unique,
 * @todo so it may be a problem but this situation is not so probable
 * @todo we can just ignore that, but it should be changed for good
 *      
 */
$app->get('/details/{unique}', function (Request $request, $unique) use($app) {
Пример #20
0
 private function createItem(Message $message)
 {
     $item = new Item();
     $item->title(utf8_encode($message->getSubject()))->description(utf8_encode($message->getMessageBody()))->url($this->url . $message->getUid() . '.html')->pubDate($message->getDate())->guid($message->getUid())->appendTo($this->channel);
     file_put_contents($this->dir . '/' . $message->getUid() . '.html', $message->getMessageBody(true));
 }
Пример #21
0
    public function test_fail_safe_against_invalid_string()
    {
        $item = new Item();
        $item->title("testtest")->url("urltest")->description("descdesc");
        $expect = '<?xml version="1.0" encoding="UTF-8"?>
<item><title>test</title><link>url</link><description>desc</description></item>
';
        $this->assertSame($expect, $item->asXML()->asXML());
    }
Пример #22
0
<?php

spl_autoload_register(function ($c) {
    @(include_once strtr($c, '\\_', '//') . '.php');
});
use Suin\RSSWriter\Feed;
use Suin\RSSWriter\Channel;
use Suin\RSSWriter\Item;
date_default_timezone_set('Europe/Vienna');
$feed = new Feed();
$channel = new Channel();
$channel->title("Ö1 " . $_GET["title"])->description("Converted RSS from 7 Tage Ö1")->url('http://oe1.orf.at/konsole')->language('de')->copyright('Copyright 2014')->pubDate(time())->lastBuildDate(time())->ttl(60)->appendTo($feed);
for ($offset = 0; $offset < 7; $offset++) {
    $streamDate = date_sub(new DateTime(NULL), new DateInterval("P" . $offset . "D"));
    $daysProgramm = json_decode(file_get_contents("http://oe1.orf.at/programm/konsole/tag/" . $streamDate->format("Ymd")));
    foreach ($daysProgramm->list as $show) {
        if (preg_match("/^" . $_GET["title"] . "\$/", $show->title)) {
            $item = new Item();
            $itemDate = DateTime::createFromFormat("d.m.YH:i", $show->day_label . $show->time);
            $item->title($show->title)->description($show->info)->enclosure($show->url_stream)->pubDate($itemDate->getTimestamp())->guid($show->id, true)->appendTo($channel);
        }
    }
}
echo $feed;
Пример #23
0
 /**
  * Display rss feeds from content category
  * @return string
  * @throws ForbiddenException
  */
 public function actionRss()
 {
     $path = $this->request->getPathWithoutControllerAction();
     $configs = $this->getConfigs();
     // build model data
     $model = new EntityCategoryList($path, $configs, 0);
     // remove global layout
     $this->layout = null;
     // check if rss display allowed for this category
     if ((int) $model->category['configs']['showRss'] !== 1) {
         throw new ForbiddenException(__('Rss feed is disabled for this category'));
     }
     // initialize rss feed objects
     $feed = new Feed();
     $channel = new Channel();
     // set channel data
     $channel->title($model->category['title'])->description($model->category['description'])->url(App::$Alias->baseUrl . '/content/list/' . $model->category['path'])->appendTo($feed);
     // add content data
     if ($model->getContentCount() > 0) {
         foreach ($model->items as $row) {
             $item = new Item();
             // add title, short text, url
             $item->title($row['title'])->description($row['text'])->url(App::$Alias->baseUrl . $row['uri']);
             // add poster
             if ($row['thumb'] !== null) {
                 $item->enclosure(App::$Alias->scriptUrl . $row['thumb'], $row['thumbSize'], 'image/jpeg');
             }
             // append response to channel
             $item->appendTo($channel);
         }
     }
     // define rss read event
     App::$Event->run(static::EVENT_RSS_READ, ['model' => $model, 'feed' => $feed, 'channel' => $channel]);
     // render response from feed object
     return $feed->render();
 }
Пример #24
0
$channel = new Channel();
$channel->title($channelTitle)->description($channelDesc)->url($channelUrl)->language($channelLanguage)->copyright($channelCopyRight)->pubDate(date("U"))->lastBuildDate(date("U"))->appendTo($feed);
// Make a new request and execute it.
try {
    $posts = (new FacebookRequest($session, 'GET', '/' . $page_id . '/posts'))->execute()->getGraphObject(GraphObject::className())->getPropertyAsArray('data');
    //print_r($posts);
    foreach ($posts as $dings) {
        $type = $dings->getProperty('type');
        $message = $dings->getProperty('message');
        if (empty($message)) {
            continue;
        }
        $id = $dings->getProperty('id');
        $title = splitMessage($message, "title");
        $content = splitMessage($message, "content");
        $createdAt = date("U", strtotime($dings->getProperty('created_time')));
        $updatedAt = strtotime($dings->getProperty('updated_time'));
        $link = $dings->getProperty('link');
        $picture = $dings->getProperty('picture');
        //print("$title: <br/>" . $content . "<br/><br/>");
        $item = new Item();
        $item->title($title)->url("https://facebook.com/{$id}")->pubDate($updatedAt)->guid("https://facebook.com/{$id}", true)->description($content)->appendTo($channel);
    }
} catch (FacebookRequestException $ex) {
    echo $ex->getMessage();
} catch (\Exception $ex) {
    echo $ex->getMessage();
}
// set the header type
header("Content-type: text/xml");
echo $feed->render();
Пример #25
0
function generate_rss($posts)
{
    $feed = new Feed();
    $channel = new Channel();
    $rssLength = config('rss.char');
    $channel->title(blog_title())->description(blog_description())->url(site_url())->appendTo($feed);
    foreach ($posts as $p) {
        if (!empty($rssLength)) {
            if (strlen(strip_tags($p->body)) < config('rss.char')) {
                $string = preg_replace('/\\s\\s+/', ' ', strip_tags($p->body));
                $body = $string . '...' . ' <a class="readmore" href="' . $p->url . '#more">more</a>';
            } else {
                $string = preg_replace('/\\s\\s+/', ' ', strip_tags($p->body));
                $string = substr($string, 0, config('rss.char'));
                $string = substr($string, 0, strrpos($string, ' '));
                $body = $string . '...' . ' <a class="readmore" href="' . $p->url . '#more">more</a>';
            }
        } else {
            $body = $p->body;
        }
        $item = new Item();
        $tags = explode(',', str_replace(' ', '', strip_tags($p->tag)));
        foreach ($tags as $tag) {
            $item->category($tag, site_url() . 'tag/' . $tag);
        }
        $item->title($p->title)->pubDate($p->date)->description($body)->url($p->url)->appendTo($channel);
    }
    echo $feed;
}
Пример #26
0
<?php

// Load test target classes
spl_autoload_register(function ($c) {
    @(include_once strtr($c, '\\_', '//') . '.php');
});
set_include_path(get_include_path() . PATH_SEPARATOR . __DIR__ . '/Source');
use Suin\RSSWriter\Feed;
use Suin\RSSWriter\Channel;
use Suin\RSSWriter\Item;
$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);
$item = new Item();
$item->title("Blog Entry Title")->description("<div>Blog body</div>")->url('http://blog.example.com/2012/08/21/blog-entry/')->pubDate(strtotime('Tue, 21 Aug 2012 19:50:37 +0900'))->guid('http://blog.example.com/2012/08/21/blog-entry/', true)->appendTo($channel);
echo $feed;
// or echo $feed->render();
Пример #27
0
function generate_rss($posts)
{
    $feed = new Feed();
    $channel = new Channel();
    $rssLength = config('rss.char');
    $channel->title(blog_title())->description(blog_description())->url(site_url())->appendTo($feed);
    foreach ($posts as $p) {
        if (!empty($rssLength)) {
            if (strlen(strip_tags($p->body)) < config('rss.char')) {
                $string = preg_replace('/\\s\\s+/', ' ', strip_tags($p->body));
                $body = $string . '...';
            } else {
                $string = preg_replace('/\\s\\s+/', ' ', strip_tags($p->body));
                $string = substr($string, 0, config('rss.char'));
                $string = substr($string, 0, strrpos($string, ' '));
                $body = $string . '...';
            }
        } else {
            $body = $p->body;
        }
        $item = new Item();
        $cats = explode(',', str_replace(' ', '', strip_tags(remove_accent($p->category))));
        foreach ($cats as $cat) {
            $item->category($cat, site_url() . 'category/' . strtolower($cat));
        }
        $item->title($p->title)->pubDate($p->date)->description($body)->url($p->url)->appendTo($channel);
    }
    echo $feed;
}
/*********************************************
 * Then the blog comments
 *********************************************/
$blogCommentFeed = new Feed();
$blogCommentChannel = new Channel();
$blogCommentChannel->title('Jacob Emerick | Blog Comment Feed');
$blogCommentChannel->description('Most recent comments on blog posts of Jacob Emerick');
$blogCommentChannel->url('https://blog.jacobemerick.com');
// todo depends on env
$blogCommentChannel->appendTo($blogCommentFeed);
$query = "\n    SELECT `comment_meta`.`id`, `comment_meta`.`date`, `comment`.`body`, `commenter`.`name`,\n           `post`.`title`, `post`.`category`, `post`.`path`\n    FROM `jpemeric_comment`.`comment_meta`\n    INNER JOIN `jpemeric_comment`.`comment` ON `comment`.`id` = `comment_meta`.`comment`\n    INNER JOIN `jpemeric_comment`.`commenter` ON `commenter`.`id` = `comment_meta`.`commenter` AND\n                                                 `commenter`.`trusted` = :trusted_commenter\n    INNER JOIN `jpemeric_comment`.`comment_page` ON `comment_page`.`id` = `comment_meta`.`comment_page` AND\n                                                    `comment_page`.`site` = :comment_site\n    INNER JOIN `jpemeric_blog`.`post` ON `post`.`path` = `comment_page`.`path` AND\n                                         `post`.`display` = :display_post\n    WHERE `comment_meta`.`display` = :active_comment\n    ORDER BY `comment_meta`.`date` DESC";
$bindings = ['trusted_commenter' => 1, 'comment_site' => 2, 'display_post' => 1, 'active_comment' => 1];
$activeBlogComments = $db->getRead()->fetchAll($query, $bindings);
foreach ($activeBlogComments as $blogComment) {
    $blogCommentItem = new Item();
    $blogCommentItem->title("Comment on '{$blogComment['title']}' from {$blogComment['name']}");
    $url = "https://blog.jacobemerick.com/{$blogComment['category']}/{$blogComment['path']}/";
    $url .= "#comment-{$blogComment['id']}";
    $blogCommentItem->url($url);
    $blogCommentItem->guid($url, true);
    $description = $blogComment['body'];
    $description = strip_tags($description);
    $description = strtok($description, "\n");
    if (strlen($description) > 250) {
        $description = wordwrap($description, 250);
        $description = strtok($description, "\n");
        if (substr($description, -1) != '.') {
            $description .= '&hellip;';
        }
    }
    $description = html_entity_decode($description);