Created
December 14, 2017 06:49
-
-
Save ermst4r/d801de55451e53ec2907d95d09ce55a7 to your computer and use it in GitHub Desktop.
ENgine
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 ini_set('display_errors', 0); | |
header('Content-Type: application/json'); | |
/** | |
* @Author: Erwin Nandpersad | |
* @website: https://www.hellospecial.com | |
* Class Engine | |
*/ | |
class Engine | |
{ | |
private $engine_username; | |
private $engine_password; | |
protected $engine_url = 'https://hellospecial.e-ngine.nl/soap/ENgineSoap.php'; | |
public function __construct($engine_username,$engine_password) | |
{ | |
$this->engine_username = $engine_username; | |
$this->engine_password = $engine_password; | |
} | |
/** | |
* Engine url | |
* @var string | |
*/ | |
/** | |
* @return string | |
*/ | |
public function getEngineUsername() | |
{ | |
return $this->engine_username; | |
} | |
/** | |
* @param string $engine_username | |
*/ | |
public function setEngineUsername($engine_username) | |
{ | |
$this->engine_username = $engine_username; | |
} | |
/** | |
* @return string | |
*/ | |
public function getEnginePassword() | |
{ | |
return $this->engine_password; | |
} | |
/** | |
* @param string $engine_password | |
*/ | |
public function setEnginePassword($engine_password) | |
{ | |
$this->engine_password = $engine_password; | |
} | |
/** | |
* @return string | |
*/ | |
public function getEngineUrl() | |
{ | |
return $this->engine_url; | |
} | |
/** | |
* @param string $engine_url | |
*/ | |
public function setEngineUrl($engine_url) | |
{ | |
$this->engine_url = $engine_url; | |
} | |
/** | |
* @param $email | |
* @param string $type | |
* @return bool | |
*/ | |
public function subscribeNewsLetter($data,$type='subscribe') | |
{ | |
ini_set('soap.wsdl_cache_enabled', '0'); | |
try { | |
$wsdl = $this->engine_url; | |
$client = new \SoapClient( | |
$wsdl, | |
array( | |
'login' => $this->engine_username, | |
'password' => $this->engine_password, | |
'trace' => 1 | |
) | |
); | |
switch($type) { | |
case 'subscribe': | |
return $client->Subscriber_set($data); | |
break; | |
case 'unsubscribe': | |
return $client->Subscriber_unsubscribe($data['email']); | |
break; | |
} | |
} catch (\SoapFault $exception) { | |
return $exception->getMessage(); | |
} | |
} | |
public function emailCheck($email) | |
{ | |
$wsdl = $this->engine_url; | |
$client = new \SoapClient( | |
$wsdl, | |
array( | |
'login' => $this->engine_username, | |
'password' => $this->engine_password, | |
'trace' => 1 | |
) | |
); | |
try { | |
$mailingListID = 4; | |
$columns = array('email', 'firstname', 'infix', 'lastname'); | |
$res = $client->Subscriber_getByEmail($email, $columns, $mailingListID); | |
return !empty($res['email']) ; | |
} catch (SoapFault $exception) { | |
// oops, something went wrong.. | |
return $exception; | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment