PHP code example of augmentedlogic / feedibus

1. Go to this page and download the library: Download augmentedlogic/feedibus library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

augmentedlogic / feedibus example snippets



use com\augmentedlogic\feedibus\Channel;
use com\augmentedlogic\feedibus\ChannelImage;
use com\augmentedlogic\feedibus\Feed;
use com\augmentedlogic\feedibus\Item;
use com\augmentedlogic\feedibus\MediaItem;


$feed = new Feed();

$channelImage = new ChannelImage();
$channelImage->url("https://example.com/icon.png")
             ->link("https://example.com/icon.png")
             ->title("Acme Ltd Logo");



$channel = new Channel();
$channel
    ->title('Channel Title')
    ->description('Channel Description')
    ->url('http://blog.example.com')
    ->feedUrl('http://blog.example.com/rss')
    ->language('en-US')
    ->image($channelImage)
    ->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') // This is optional. Specify PubSubHubbub discovery if you want.
    ->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) // By this, title and description become CDATA wrapped HTML.
    ->source('http://blog.example.com/')
    ->appendTo($channel);


// Media RSS item
$mediaitem = new MediaItem();
$mediaitem ->url("https://www.example.com")
           ->title("Oh my wonderful RSS", "plain")
           ->filesize(5020281)
           ->filetype("audio/mpeg")
           ->medium("audio")
           ->width(1920)
           ->height(1080)
           ->bitrate(2500)
           ->framerate(25)
           ->samplingrate(44.1)
           ->channels(2)
           ->lang("en")
           ->thumbnail("https://example.com/image.jpg")
           ->thumbnailWidth(900)
           ->thumbnailHeight(600)
           ->expression("full")
           ->description("a wonderful song")
           ->keywords(array("rock", "blues"))
           ->playerUrl("https://example.com")
           ->playerWidth(1920)
           ->playerHeight(1080);
           ->hash('bf1ab2d7290a1bed086fdab56f268f48', 'md5');

 
$item = new Item();
$item
    ->title('Some Media RSS Entry')
    ->description('<div>Podcast body</div>')
    ->url('http://podcast.example.com/2012/08/21/podcast-entry/')
    ->media($mediaitem)
    ->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();


use com\augmentedlogic\feedibus\Channel;
use com\augmentedlogic\feedibus\ChannelImage;
use com\augmentedlogic\feedibus\GeoRSSFeed;
use com\augmentedlogic\feedibus\Item;
use com\augmentedlogic\feedibus\MediaItem;


$feed = new GeoRSSFeed();
 
$channel = new Channel();
$channel->title('Channel Title')
    ->description('Channel Description')
    ->url('http://blog.example.com')
    ->appendTo($feed);
 
$item = new Item();
$item
    ->title('Some Geo Entry')
    ->description('This is London')
    ->url('http://example.com/london')
    ->point(51.5074, -0.1278) // point is lat, lon
    ->appendTo($channel);
 
echo $feed->render();