Here is an example code which you can use to create campaign in your Post Affiliate Pro through API:
 
<?php

include 'PapApi.class.php'; //this include assumes the PapApi.class.php is in the same directory as this api script itself

$session = new Pap_Api_Session("https://URL_TO_YOUR_PAP_INSTALLATION/scripts/server.php");

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

$request = new Gpf_Rpc_FormRequest("Pap_Merchants_Campaign_CampaignForm", "add", $session);
$request->setField("Id",""); // Id should be blank, it is populated automatically
$request->setField("name","name of the campaign"); // Name of the campaign. MANDATORY
$request->setField("logourl",""); // URL to campaign's logo. OPTIONAL
$request->setField("description","Campaign's description"); // Campaign's description. OPTIONAL
$request->setField("cookielifetime","365"); // Cookie lifetime in days. 365 = maximum. MANDATORY
$request->setField("overwritecookie","D"); // Overwrite cookie setting. D = default, Y = Yes, N = No. MANDATORY
$request->setField("productid","test"); // List of product IDs for product id matching. OPTIONAL
$request->setField("rstatus","A"); // Campaign's status. MANDATORY// A - active// S - stopped (invisible)// W - stopped (visible)// T - active for datarange// L - active until X results delivered
$request->setField("rtype","P"); // Type of campaign. MANDATORY// P - public// M - public with manual approval// I - visible only for invited affiliates
$request->setField("accountid","default1"); // Merchant's account id. MANDATORY.// Should be default1 in PAP
try  {
    $request->sendNow(); // Send form request to Post Affiliate Pro
    } 
    catch(Exception $e){
        die("API call error: " . $e->getMessage());
        }
$response = $request->getStdResponse(); // Get the response as normal array
?>
 
 
×