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.
<?php
  include 'affiliate/api/PapApi.class.php';
  
  $session = new Pap_Api_Session("http://localhost/affiliate/scripts/server.php");
  if(!$session->login("merchant@example.com", "demo")) {
    die("Cannot login. Message: ".$session->getMessage());
  }else{
    echo "Success";
  }
  $request = new Gpf_Rpc_FormRequest("Pap_Features_CommissionGroups_AffiliateGroupForm", "add", $session);
  // Id should be blank, it is populated automatically
  $request->setField('Id','');

  // Affiliate's user id.
  $request->setField('userid','252da3f5');

  // Affiliate's status in the commission group.
  // A = Approved, R = Ascending, F = Descending, X = Fixed
  $request->setField('rstatus','A');

  // Note about the affiliate in the commission group
  $request->setField('note','');

  // Commission group id
  $request->setField('commissiongroupid','7afb3b88');

  // Campaign id in which is the commission group
  $request->setField('campaignid','11111111');
  
  try  {
    // Send the request to PAP
    $request->sendNow();
  } 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: http://support.qualityunit.com/235875-How-to-get-commission-group-id.