PHP code example of cyberomulus / podcast-generator

1. Go to this page and download the library: Download cyberomulus/podcast-generator 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/ */

    

cyberomulus / podcast-generator example snippets


	// do not forget to import the classes
	us\PodcastGenerator\Podcast;
	use Cyberomulus\PodcastGenerator\Media;
	
	// create a podcast
	$podcast = new Podcast(
			"A Title for my Podcast",
			"A description for my Podcast",
			"http://www.mysite.com",
			"http://www.mysite.com/img/podcast.jpg",
			"My Name",
			"music",
			"A subtitle for my Podcast",
			null, // I do not wish to specify language
			null, // I do not wish to specify email
			null, // I do not wish to specify copyright
			null, // I've yet to add media
			true  // I activate the injection mode
			);
	
	// we will put the media in a array
	// This is not mandatory but useful when transmitting them to the podcast media
	$medias = array();
	
	// create a first media
	$medias[] = new Media(
			"Broadcast of 23/01/15", 
			new DateTime("2015-01-23"), 
			"http://www.mysite.com/media/fichier1.mp3", 
			"audio/mpeg", 
			"a_unique_guid_in_all_internet", 
			"15:05",
			"A specific description for this media",
			null, // I do not want to specify a specific subtitle for this media
			null, // I do not want to specify a specific link for this media
			null, // I do not want to specify a specific author for this media
			null // I do not want to specify a specific image for this media
			);
	
	// create a second media
	$medias[] = new Media(
			"Broadcast of 24/01/15",
			new DateTime("2015-01-24"),
			"http://www.mysite.com/media/fichier2.mp3",
			"audio/mpeg",
			"a_another_unique_guid_in_all_internet",
			"1:01:48",
			null, // I do not want to specify a specific description for this media
			"A friend visit me in studio",
			null, // I do not want to specify a specific link for this media
			"My name + Name of my friend",
			null // I do not want to specify a specific image for this media
			);
	
	// transmit all medias in podcast
	// I can send a array (a merging will do) 
	// but also a Media object only (will be added to the list)
	$podcast->addMedia($medias);
	
	// to display the XML document
	header ("Content-Type:text/xml");
	echo $podcast->toXML();
	// same as :
	// echo $podcast->toString();
	
	// but it is possible to recover the DOM document for editing
	$dom = $podcast->toDom();