<?php

// the PapApi.class.php file can be downloaded from the merchant panel at:
// Tools > Integration > API Integration > Download PAP API
// This include assumes the PapApi.class.php file is in the same directory as this particular script.
include 'PapApi.class.php';
$session = new Pap_Api_Session("https://URL_TO_PAP/scripts/server.php");

//user your merchant username and password below
if(!$session->login("Merchant Username","Merchant Password")) {
  die("Cannot login. Message: ". $session->getMessage());
}

$request = new Gpf_Rpc_FormRequest("Pap_Merchants_Banner_BannerForm", "add", $session);

//$request->setField('bannerid','11223344'); //uncomment this line if you want to use own bannerid (it have to be 8 characters)

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

// Type of banner. MANDATORY
// F - flash, H - html, I - image, A - link banner, V - pdf, P - popup, E - promoemail,  
// T - textlink, R - rotator, S - replicated site, X - rebrand pdf, Z - zip banner, C - coupon banner
$request->setField('rtype','I');

// 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 (coupon banner, etc.)
// P - predefined, format: P:120x40 
// O - own, format: 25x25
$request->setField("size","O");

// Banners's width and height in pixels. 
// Essential if "O" is set in 'size' above.
$request->setField("size_width","160");
$request->setField("size_height","60");

// Essential if setField("size","P") was used above
//$request->setField("size_predefined","250x250");

// SEO string. OPTIONAL
$request->setField("seostring","");

// Banner's Destination URL. MANDATORY
// NOT NEEDED in case of Coupon banner
$request->setField("destinationurl","https://yoursite.com/whateversubpage/anything.php");

// Data1. MANDATORY
// banner file URL in case of image, flash or pdf banner. 
// title in case of Text Link, Promo email or Link Banner
// "Detailed description" field of the Coupon banner
$request->setField("data1","https://yoursite.com/images/someImage.jpg");

// Data2. MANDATORY/OPTIONAL
// Text in case of text link banner. -- Optional
// HTML code in case of  Html banner, simple pdf banner, promo e-mail banner.  -- Mandatory
// Maximum number of coupons per affiliate (has to be a positive integer value)
$request->setField("data2","some alternative text if the image does not show up");

// Wrapperid. MANDATORY
// plain, jsdynam, iframe, popunder, popup 
// In case of own wrappers, the wrapper id can be found in the Configuration > Banners & Links Formats
$request->setField("wrapperid","plain");

// Target attribute. OPTIONAL
// _top, _blank
$request->setField("target","_top");

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();

// Get response message
if ($response->success == 'Y') {
  echo 'Success: ' . $response->message;
} else {
  echo 'Unsuccess: ' . $response->message;
}
?>
×