Create new channel
Started by Kevin on January 13th, 2010 05:27 | return to category | Follow by RSS
Can you show me a quick way to create a new channel using the api. I am comfortable with the api for the most part but I can't figure out how to create a new channel.
JeroenW
January 13th, 2010 11:02Using the PHP API kit, you can do the following:
<?php
# Instantiate the PHP API Kit.
require_once('botr/api.php');
$botr_api = new BotrAPI('xxxx', 'yyyy');
# Create the (dynamic) channel.
$response = $botr_api->call('/channels/create',array('type'=>'dynamic'));
if($response['error']) { die($response); }
$channel_key = $response['channel']['key'];
# Set some channel properties.
$response = $botr_api->call('/channels/update',
array('channel_key'=>$channel_key,'title'=>'Last 5','videos_max'=>5));
if($response['error']) { die($response); }
# Preview the channel.
echo "<a href='http://content.bitsontherun.com/previews/$channel_key-0ZDVNwjY'>Preview channel</a>";
?>
This creates a dynamic channel, which is easy because videos are automatically inserted. With manual channels, you should use the /channels/videos calls to add videos one by one.
Kevin
January 13th, 2010 17:44Great, thanks!
The 2 separate api calls confused me when reading the documentation.
This is exactly what I needed.