1. Created (imported) coupons will have to be assigned manually to affiliates
<?php //your PapApi.class.php file can be downloaded in the merchant panel: Tools>Integration>API Integration>Download PAP API include ("PapApi.class.php"); //this include assumes the PapApi.class.php is in the same dir as this script //change localhost/pap to the path of your Post Affiliate Pro installation $session = new Pap_Api_Session("https://localhost/pap/scripts/server.php"); //login as merchant (in PAN as Network-Owner) if(!$session->login("merchant@example.com","demo")) { die("Cannot login. Message: ". $session->getMessage()); } $request = new Gpf_Rpc_Request("Pap_Features_Coupon_CreateCoupons", "import", $session); $request->addParam('fields', new Gpf_Rpc_Array(array(array('name', 'value'), array("Id", "b18fcc52"), //banner ID of the coupon banner array("validfrom","2013-10-03"), array("unlimitedValidity","N"), //validity of coupons is NOT UNLIMITED array("validto","2013-10-04"), array("maxusecount","0"), array("couponassigment","R"), //Coupons will have to be manually assigned to affiliates. array("couponcodes","xyz123,vxyz12") ))); try { $request->sendNow(); } catch(Exception $e) { die("API call error: ".$e->getMessage()); } $response = $request->getStdResponse(); if ($response->success == 'Y') { echo 'Success: ' . $response->message; } else { echo 'Unsuccess: ' . $response->message; } ?>
Then you can use another API to manually assign created coupons to desired affiliates:
2) Created (imported) coupons will be automatically and randomly assigned to affiliates.
Therefore it is essential to generate at leaset as many coupons as we have affiliates. More exactly:
"Number Of Affilaites" * "Coupon per Affiliate" * 110%
<?php //your PapApi.class.php file can be downloaded in the merchant panel: Tools>Integration>API Integration>Download PAP API include ("PapApi.class.php"); //this include assumes the PapApi.class.php is in the same dir as this script //change localhost/pap to the path of your Post Affiliate Pro installation $session = new Pap_Api_Session("https://localhost/pap/scripts/server.php"); //login as merchant (in PAN as Network-Owner) if(!$session->login("merchant@example.com","demo")) { die("Cannot login. Message: ". $session->getMessage()); } $request = new Gpf_Rpc_Request("Pap_Features_Coupon_CreateCoupons", "import", $session); $request->addParam('fields', new Gpf_Rpc_Array(array(array('name', 'value'), array("Id", "b18fcc52"), //banner ID of the coupon banner array("validfrom","2013-10-03"), array("unlimitedValidity","Y"), //validity of coupons is UNLIMITED array("validto",""), //therefore the validto value has to remain empty array("maxusecount","0"), array("couponassigment","A"), //Coupons will be automatically and randomly assigned to affiliates. array("couponsperaff","1"), // 1 coupon per affiliate array("couponcodes","xyz1,xyz2,xyz3") //We must create at least as many coupons as we have affiliates //More exactly: NumberOfAffilaites * CouponPerAffiliate * 110% ))); try { $request->sendNow(); } catch(Exception $e) { die("API call error: ".$e->getMessage()); } $response = $request->getStdResponse(); if ($response->success == 'Y') { echo 'Success: ' . $response->message; } else { echo 'Unsuccess: ' . $response->message; } ?>