Add a Replicated site banner via API

This is a sample code of how to create a Replicated site banner via API.
 
 
<?php
$papURL = "https://URL_TO_PostAffiliatePro"; //URL of your Post Affiliate Pro installation without any trailing slash
$merchantUsername = "merchant@example.com"; //merchant username
$merchantPassword = "123456"; //merchant password

//your PapApi.class.php file can be downloaded in the merchant panel:
//Tools>Integration>API Integration>Download PAP API
include_once ("PapApi.class.php"); //this include assumes the PapApi.class.php is in the same dir as this script

$session = new Pap_Api_Session($papURL."/scripts/server.php");   
//$session->setDebug(); 

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

$request = new Gpf_Rpc_FormRequest("Pap_Merchants_Banner_BannerForm", "add", $session);
// Id should be blank, it is populated automatically
$request->setField('Id','');

// Name of the banner. MANDATORY
$request->setField('name','Name of the banner');

// Type of banner. MANDATORY
//S - replicated site
$request->setField('rtype','S');

// Banner status. MANDATORY
// A - active (not hidden), H - hidden (invisible), S - stopped (invisible)
$request->setField("rstatus","A");

// Campaign ID. MANDATORY
$request->setField('campaignid','11111111');

// Banner description. OPTIONAL
$request->setField("description","Banner description visible in the affiliate panel");

// Banner size. MANDATORY
// U - undefined
$request->setField("size","U");


// Banner's Destination URL. MANDATORY
// base URL of replicated site to which later on the referral id of affiliate will be appended
// when the affiliate looks up this banner in the affiliate panel
$request->setField("destinationurl","https://www.example.com/VIPsites/");


// Data1. MANDATORY
// base URL of replicated site that to which later on the referral id of affiliate will be appended
// when the affiliate looks up this banner in the affiliate panel
// NOTE: It is similar to the 'destinationurl' but starts with a capital "C" and does not have a trailing slash
$request->setField("data1","Chttps://www.example.com/VIPsites");

// Data2. MANDATORY
// file types to be replicated
$request->setField("data2","*.html,*.htm,*.php");

// Data3. MANDATORY
// E =  replicate external URL (defined in 'data4')
$request->setField("data3","E");

// Data4. Mandatory
// URL to directory in which the files to be replicated can be found
$request->setField("data4","https://files.to.process.com/some/directory/");

// Data5. OPTIONAL
// recognize %7B, %7D, and %24 as '{', '}', and '$'
// possible values: "N" or "Y"
$request->setField("data5","N");

// Data6. OPTIONAL
// use default affiliate for wrong or empty Affiliate_Refid
// possible values: "N" or "Y"
$request->setField("data6","Y");

try  {
// Send the request to PAP
    $request->sendNow();	
} catch(Exception $e){
    die("API call error: " . $e->getMessage());
}

// Get the response as normal array
$response = $request->getStdResponse();
echo "<hr>Value of response->success: ".$response->success."<hr>";

//Get the form response as normal array
$responseForm = $request->getForm();
echo "Value of responseForm->isSuccessful(): ".$responseForm->isSuccessful()."<hr>";


if ($responseForm->isSuccessful()) {
    echo "<hr>Banner id of freshly created Replicated site banner is:<br>".$responseForm->getFieldValue('bannerid');	
}
?>
NOTE: Once a replicated site banner is created it is essential to have the corresponding .htaccess file to be placed into the directory reached by the 'URL of replicated site' -- more info here:
https://support.qualityunit.com/376004-Replicated-Site-URL
 
×