Add commission group to a campaign via API

The following sample code shows how to add a commission group to a campaign. 
It behaves the same way as if you added a commission group to a  campaign through the merchant panel, so the commission types that you already have in a campaign will be automatically created within the freshly added/created commission group.
//the PapApi.class.php can be downloaded from the merchant panel at Tools > Integration > API Integration > Download PAP API
include 'PapApi.class.php'; //this include assumes the PapApi.class.php is in the same directory as this api script itself

$papURL = "http://URL_TO_POST_AFFILIATE_PRO"; //URL to PAP/PAN without any trailing slash
$merchantUsername = ""; //merchant username
$merchantPassword = "password"; //merchant password

$session = new Pap_Api_Session($papURL."/scripts/server.php");

//log in as merchant
if(!@$session->login($merchantUsername,$merchantPassword)) {
  die("Cannot login. Message: ". $session->getMessage());

$request = new Gpf_Rpc_FormRequest("Pap_Features_CommissionGroups_CommissionGroupsForm", "add", $session);
// Id should be blank, it is populated automatically

// Name of the commission group. MANDATORY
$request->setField("name","name of the commission group");

// Priority of commission group - 1,2,3 ...

// Cookie lifetime of commisison group
// Possible values: "-1" = "Same as cookie lifetime of the campaign", 
// or number of days, e.g. 65

//ID of campaign to which the commission group shall be added

try  {
// Send the request to PAP
} catch(Exception $e){
die("API call error: " . $e->getMessage());

// Get the response as normal array
$response = $request->getStdResponse();