Help & Support
How do I automate creating channels with the Channel API?
Cbox Pro provides a very simple API for creating new channels on the fly.
At the Channels page in your control panel you will find your secret API URL. You can open this URL directly in your browser to test it, but it's intended to be called by back-end scripts running on your own site.
The return format for this call is a single line of tab-separated plain-text fields. If there was an error, the first field is "FAIL" and the second field is an error code. If a new thread was successfully generated, the first field is "OK", and the second and third fields are the thread ID and thread key, respectively.
By way of example, this very simple PHP script will generate threads for your Cbox. New threads created via the API will show up in your control panel, but you should store the thread ID and key in your own database as well.
<?php $cb_tid = null; $cb_tkey = null; $cb_rs = file_get_contents('YOUR_API_URL', 'r'); $cb_rp = explode("\t", $cb_rs); if ($cb_rp[0] === 'FAIL') { // There was an error. // $cb_rp[1] contains the error code } else if ($cb_rp[0] === 'OK') { // Success $cb_tid = $cb_rp[1]; $cb_tkey = $cb_rp[2]; } else { // Some other error occured. } if ($cb_tid && $cb_tkey) { // New key generated. Store $cb_tid and $cb_tkey in your database or user session. // And insert them into your Cbox HTML code iframe src URLs: // ....&sec=main&tid=<?php echo $cb_tid;?>&tkey=<?php echo $cb_tkey;?> // ....&sec=form&tid=<?php echo $cb_tid;?>&tkey=<?php echo $cb_tkey;?> } ?>