Adding affiliate to commission group

Here is an example how to add affiliate to commission group. This example assumes that you already know the desired affiliate id, campaign id and commission group id.
  include 'affiliate/api/PapApi.class.php';
  $session = new Pap_Api_Session("http://localhost/affiliate/scripts/server.php");
  if(!$session->login("", "demo")) {
    die("Cannot login. Message: ".$session->getMessage());
    echo "Success";
  $request = new Gpf_Rpc_FormRequest("Pap_Features_CommissionGroups_AffiliateGroupForm", "add", $session);
  // Id should be blank, it is populated automatically

  // Affiliate's user id.

  // Affiliate's status in the commission group.
  // A = Approved, R = Ascending, F = Descending, X = Fixed

  // Note about the affiliate in the commission group

  // Commission group id

  // Campaign id in which is the commission group
  try  {
    // Send the request to PAP
  } catch(Exception $e){
    die("API call error: " . $e->getMessage());

  // Get response. Not required, but you might want to know if it was successful.  
  $response = $request->getStdResponse();
  // Display the response
  echo '<pre>' . print_r($response,true) . '</pre>';

Example how to retrieve the commission group id for a campaign you can find here: