Order Now AdSolution Sign Up | Login » Bits on the Run Sign Up | Login »

Forums

/

Create new channel

2 replies [Last post]

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.

Using 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 <a rel="no follow" href="http://www.bitsontherun.com/documentation/system-api/methods/index.html#channels-videos">/channels/videos calls</a> to add videos one by one.

Great, thanks!

The 2 separate api calls confused me when reading the documentation.

This is exactly what I needed.