include_once("<span>/</span>var<span>/</span>www/html/affiliation/api/PapApi.class.php");
$Juser = CBuser::getUserDataInstance( "[user_id]" );
// get data from CB
$cbpapid = "[USERNAME]";
$cbparentid = "[cb_codeparrainpartenaire]";
// params info
$pap4Url = '[cb:config param="live_site" /]/affiliation/scripts/server.php';
$pap4Username = "xxxxxx";
$pap4Pwd = "xxxxxx";
try {
$session = new Gpf_Api_Session($pap4Url);
if (!$session->login($pap4Username, $pap4Pwd)) {
die("Message erreur : ".$session->getMessage());
}
// get affiliate with pap id = USERNAME
$affiliate = new Pap_Api_Affiliate($session);
$affiliate->setRefid($cbpapid, Pap_Api_Affiliate::OPERATOR_EQUALS );
try {
$affiliate->load();
}
catch (Exception $e) {
//affiliate not exists needs to be registered on PAP
// convert the user parameters to a format for the external application
$args = array();
$args["email"] = "[EMAIL]";
$args["fname"] = "[firstname]";
$args["lname"] = "[lastname]";
$args["refid"] = "[USERNAME]";
$args["parentuserid"] ="[cb_parrain]";
$args["password"] = "[cb_passaffiliation]";
$args["data3"] = "[cb_address]";
$args["data4"] = "[city]";
$args["data6"] = "[cb_pays]";
$args["data7"] = "[zipcode]";
// create new affiliate
$affiliate->setUsername($args["email"]);
$affiliate->setPassword($args["password"]);
$affiliate->setFirstname($args["fname"]);
$affiliate->setLastname($args["lname"]);
$affiliate->setRefid($args["refid"]);
$affiliate->setParentUserId($args["parentuserid"]);
$affiliate->setData(3,$args["data3"]);
$affiliate->setData(4,$args["data4"]);
$affiliate->setData(6,$args["data6"]);
$affiliate->setData(7,$args["data7"]);
if(!$affiliate->add()) {
die("Message: Merci de prendre contact avec nous, votre parrainage est inactif ".$session->getMessage());
}
//die('Message: '.$session->getMessage());
}
//retrieve the parent id to update CB field
$parentid = htmlspecialchars($affiliate->getParentUserId());
$refid = htmlspecialchars($affiliate->getUserid());
$Juser->cb_refid = $refid;
$Juser->cb_codeparrainpartenaire = $parentid;
$Juser->store();
}
catch (Exception $e) {
die('Error while communicating with PAP: '.$e->getMessage());
}
Please Log in to join the conversation.
Please Log in to join the conversation.
$pap4Url = str_replace( 'https', 'http', [cb:config param="live_site" /], 1 ) . '/affiliation/scripts/server.php';
Please Log in to join the conversation.
It always outputs whatever Joomla provides as the live_site
$pap4Url = '[cb:config param="live_site" /]/affiliation/scripts/server.php';
$u =& JURI::getInstance( $pap4Url );
$u->setScheme( 'http' );
$session = new Gpf_Api_Session($u);
Please Log in to join the conversation.
We didn't change anything. Most likely you changed a Joomla setting. Whether it's globally forcing HTTPS or setting your live_site URL in configuration.php. Could also be a change in a Joomla release. The code for CB to return live_site has been untouched for probably over a year now as there's no reason to touch it. It's possible something else installed could be modifying JURI::base() (CB does not).We did not have this problem until last week and use this substitution all over the website.
So this has to be with a change that you introduced in latest builds somewhere.
Faster to just do a simple str_replace instead of building an entire URI object for it.Hope it's ok ?
No, it is and always will be whatever Joomla has JURI::base() set to.Cannot you make the live site defaults to http ? and then use a string replace to https ?
It uses whatever scheme you're viewing the site as unless you've configured Joomla to globally force HTTPS or it uses whatever URL you specified as live_site in configuration.php.Because 'm not sure that the JURI::base() always keeps the same protocol...
Please Log in to join the conversation.
Faster to just do a simple str_replace instead of building an entire URI object for it.
Most likely you changed a Joomla setting. Whether it's globally forcing HTTPS or setting your live_site URL in configuration.php. Could also be a change in a Joomla release.
Please Log in to join the conversation.