Last active
October 29, 2020 17:48
-
-
Save danlefebvre/0b62a56bb009f1bf985365051a7d1f30 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$response = array(); | |
$email = General::sanitize($postData['form']['email']); | |
$firstname = General::sanitize($postData['form']['firstname']); | |
$lastname = General::sanitize($postData['form']['lastname']); | |
if( isset($postData['form']['language']) && $postData['form']['language'] ){ | |
$language = General::sanitize($postData['form']['language']); | |
} else { | |
$language = Lang::get(); | |
} | |
$config = Symphony::Configuration()->get('adnetis'); | |
$form_data = $formEntry->getData(FormDyn::getFormNameFieldId()); | |
$form_handle = $form_data['handle']; | |
if ($form_handle != 'evenement-tour-horizon' && (!isset($postData['form']['newsletter']) || $postData['form']['newsletter'] !== 'oui')) { | |
return $response; | |
} | |
if (empty($email) || empty($firstname) || empty($lastname)) { | |
return $response; | |
} | |
$listsID = []; | |
if( isset($postData['form']['newsletter']) && $postData['form']['newsletter'] == 'oui' ){ | |
$listsID[] = (int)$config['list']; | |
} | |
//Event Tour d'horizon, subscribed just by filling the form | |
if( $form_handle == 'evenement-tour-horizon' ){ | |
$listsID[] = (int)$config['list_event']; | |
} | |
// Connect to the SOAP service and get the results | |
$soap_client = new SoapClient("http://solutions-emailing.com/sews/wsapi.asmx?WSDL", | |
array( | |
"trace" => 1, // enable trace to view what is happening | |
"exceptions" => 0, // disable exceptions | |
"cache_wsdl" => 0) // disable any caching on the wsdl, encase you alter the wsdl server | |
); | |
$list = $soap_client->loginMethod(array('strLogin' => $config['user'], 'strPassword' => $config['password'])); | |
$result = $list->loginMethodResult; | |
$headers = $soap_client->__getLastResponseHeaders(); | |
$sessionPos = strpos($headers, "ASP.NET_SessionId="); | |
$cookieValue = substr($headers, $sessionPos + 18,25); | |
$soap_client->__setCookie('ASP.NET_SessionId', $cookieValue); | |
// The first four an mandatory | |
$data = 'EMAIL;LANG;DISPLAY;BIRTHDAY;IDENTIFICATOR'.PHP_EOL; | |
$data .= $email . ';' . $language . ';' . $firstname . ';;'. $lastname . PHP_EOL; | |
$result = json_encode($soap_client->updDBCSV3(array('data' => $data, 'listsID' => $listsID, 'sublistsID' => array(), 'Delimiter' => ';'))); | |
$result = json_decode($result, JSON_FORCE_OBJECT); | |
if (strpos($result['updDBCSV3Result'], 'Created : 1') !== false) { | |
$response['success'] = 'yes'; | |
} elseif (strpos($result['updDBCSV3Result'], 'Updated : 1') !== false) { | |
$response['success'] = 'yes'; | |
} elseif (strpos($result['updDBCSV3Result'], 'Unsubscribed/Bounced : 1') !== false) { | |
$response['success'] = 'yes'; | |
} else { | |
$response['success'] = 'no'; | |
$response['body'] = $result; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment