You can use the following code to add (or remove) a specific campaign to Campaigns Categories. You'll need to know the IDs of the categories to which you want to add the campaign or remove it from, you can get these IDs by loading all the categories as explained here.
To add a campaign to a category you must set the category's "selected" attribute to Y and to remove you must set "selected" to N. This is essentially a patch request so you don't need to list all current categories, you'd list only the categories which you want to change somehow.
<?php $papURL = "https://SOMETHING.postaffiliatepro.com/scripts/server.php"; // replace with your Post Affiliate Pro URL address $merchantUsername = "merchant@username.com"; $merchantPassword = "password"; //your PapApi.class.php file can be downloaded in the merchant panel: //Tools>Integration>API Integration>Download PAP API require "PapApi.class.php"; //this include assumes the PapApi.class.php is in the same dir as this script $session = new Pap_Api_Session($papURL); //login as merchant if(!@$session->login($merchantUsername, $merchantPassword)) { die ("Cannot login. Message: ".$session->getMessage()); } $request = new Gpf_Rpc_Request('Pap_Features_CampaignsCategories_EditableCategoriesGrid', 'saveCategories', $session); $request->addParam('campaignid', '5ec43fb4'); // enter ID of the campaign you wish to change categories for $request->addParam('fields', new Gpf_Rpc_Array(array( array('id', 'name', 'value'), array('3', 'selected', 'Y'), // set the ID / code of the category to which the campaign should belong, you can use this approach to load all existing categories https://support.qualityunit.com/591172-Load-the-whole-Campaigns-Categories-tree array('5','selected', 'Y')))); // selected is set to Y when you want to add the campaign to this category and to N when you want to remove the campaign from this category try { $request->sendNow(); } catch(Exception $e) { die("API call error: ".$e->getMessage()); } $response = $request->getStdResponse(); if ($response->success == 'Y') { echo 'Successful: ' . $response->infoMessage; } else { echo 'Unsuccessful: ' . $response->errorMessage; } ?>