示例#1
0
 *
 * @apiSuccessExample {json} Success-Response:
 *     201 OK
 *     {
 *       "title": "Capira Channel",
 *       "id": "42",
 *       "parent": "314"
 *     }
 * @apiUse NotPermitted
 * @apiUse MissingParameter
 *
 */
$app->post('/channel', function () use($app) {
    include_once 'libs/channel.php';
    $channel = $app->request->getBody();
    echo json_encode(createChannel($channel));
});
/**
 *
 * @api {PUT} /channel/ 		Update a channel
 * @apiName updateChannel
 * @apiGroup Channel
 * @apiVersion 1.0.0
 *
 * @apiParam {String} title   	Title of new Channel
 * @apiParam {Number} parent  	Parent Id of new Channel
 *
 * @apiPermission Author of the Channel
 * @apiUse NotPermitted
 * @apiUse MissingParameter
 * @apiSuccessExample {json} Success-Response:
示例#2
0
        //Loop through array to create each channel
        foreach ($channel_info as $key => $value) {
            //Merge custom channel information with default settings
            $merged_array = $value + $channel_deafults;
            // preserves keys
            //If first channel create Master-Parent channel
            if ($key == 0) {
                //Create Channel Function: Create channel + record channels CID for parenting
                $parent_id = createChannel($tsAdmin, $merged_array, $permissions_deafult);
                moveClients($tsAdmin, $parent_id);
                //Create sub-channels of Master-Parent channel
            } else {
                //Add Master-Parent CID to channel information
                $merged_array = $merged_array + ($arrayName = array("cpid" => $parent_id['data']['cid']));
                //Create Channel Function: create sub-channel
                createChannel($tsAdmin, $merged_array, $permissions_deafult);
                //Will require an extra IF check to see if channel is also a parent channel!
            }
        }
    } else {
        echo 'API Error: No channel information has been entered, cannot create channels <br>';
    }
    #Set message for TS & Web
    #$tsmessage = 'Success';
    #send message to Teamspeak
    #$tsAdmin->sendMessage($mode, $target, $tsmessage);
} else {
    echo 'Application could not establish a connection to the TS Server with IP: ' . $ts3_ip . '<br>';
}
/*-------Functions-------*/
//Create Channel Function (TS_Object, Channel_Information, Channel_Permissions)