// 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

// Banner status. MANDATORY
// A - active (not hidden), H - hidden (invisible), S - stopped (invisible)

// Campaign ID. MANDATORY

// 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

// Banners's width and height in pixels. 
// Essential if "O" is set in 'size' above.

// Essential if setField("size","P") was used above

// SEO string. OPTIONAL

// Banner's Destination URL. MANDATORY
// NOT NEEDED in case of Coupon banner

// 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

// 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

// Target attribute. OPTIONAL
// _top, _blank

try  {
// Send the request to PAP
} 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;