Add product ID to existing campaign via API

The following code is an example of how to add product id(s) to an existing campaign.
NOTE: it will replace the existing product IDs. If you wish to keep the existing product IDs, then first you have to load the campaign and its product IDs and add them again along with the new product ids.
$papURL = "https://URL_TO_PAP"; //URL to PAP/PAN without trailing slash
$merchantUsername = ""; //replace with your username
$merchantPassword = "merchant password"; //replace with your password

//the PapApi.class.php can be downloaded from the merchant panel:
//Tools > Integration > API Integration > Download PAP API
include 'PapApi.class.php'; 

$session = new Pap_Api_Session($papURL."/scripts/server.php");
if(!$session->login($merchantUsername, $merchantPassword)) {	
	die("Login failed: ".$session->getMessage());

$request = new Gpf_Rpc_FormRequest("Pap_Merchants_Campaign_CampaignForm","save",$session);
$request->setField("Id","11111111"); //ID of campaign to which you wish to add product id(s)
$request->setField("productid","Productid1,Porductid2,ProductId3"); //Product Id(s) separated by comma

try {
  echo "Product Id(s) have been successfully added";
} catch(Exception $e) {
  die("API call error: ".$e->getMessage());