*/
class EpaperApikeyApi
{
private $apikeyApiClient;
private $ApikeyApiWsdl;
private $apikey;
private $epaperOptions;
private $isRegistered;
protected $accountmanagerApiOptionIndex = 'plugin_epaper_options';
public function __construct()
{
$this->epaperOptions = get_option($this->accountmanagerApiOptionIndex);
$this->apikey = isset($this->epaperOptions['apikey'])?$this->epaperOptions['apikey']:NULL;
$this->apikey_as = isset($this->epaperOptions['apikey_as'])?$this->epaperOptions['apikey_as']:NULL;
$this->ApikeyApiWsdl = $this->epaperOptions['wordpressapi'];
$this->epaperApikeyApiConnect();
$this->checkVersion();
$this->_isRegistered();
}
public function getRssUrl(){
return false;
}
public function getOptionIndex(){
return $this->accountmanagerApiOptionIndex;
}
public function getAppUrl(){
return false;
}
public function refreshKeys(){
$this->checkVersion(true);
}
private function checkVersion($bForceRefresh = false){
if( (isset($this->epaperOptions['email'])
&& !isset($this->epaperOptions['apikey_as'])
&& (isset($this->epaperOptions['apikey']) && !empty($this->epaperOptions['apikey']) )
) || $bForceRefresh == true):
if($this->ApikeyApiWsdl != TGE_PLUGIN_ACCOUNT_API_URI){
$this->epaperOptions['wordpressapi'] = TGE_PLUGIN_ACCOUNT_API_URI;
$this->ApikeyApiWsdl = $this->epaperOptions['wordpressapi'];
}
try {
$sJson = $this->apikeyApiClient->refreshAccApiKeyByCmsApiAndEmail(
$this->epaperOptions['apikey'],
$this->epaperOptions['email'],
get_bloginfo('language'),
get_bloginfo('url'),
get_bloginfo('version'));
//return $sApiKey;
} catch (SoapFault $e) {
_e("Error with Apikey API.",'1000grad-epaper');
echo $e->getMessage();
}
$aData = json_decode($sJson);
if(isset($aData->apikey_as)):
$this->epaperOptions['apikey_as'] = $aData->apikey_as;
update_option("plugin_epaper_options", $this->epaperOptions);
endif;
endif;
}
/**
* Shall validate if plugin is registered
*/
private function _isRegistered ()
{
if (isset($this->apikey) && ($this->apikey != "")) {
$this->isRegistered = true;
} else {
$this->isRegistered = false;
}
}
/**
* Connect
*/
public function epaperApikeyApiConnect()
{
$wsdl = $this->ApikeyApiWsdl;
try {
$this->apikeyApiClient = new SoapClient($wsdl , array());
return true;
} catch (SoapFault $e) {
return false;
}
return false;
}
/**
* Versionsabfrage
*/
public function getApikeyApiVersion()
{
try {
$version = $this->apikeyApiClient->getVersion();
return $version;
} catch (SoapFault $e) {
_e("Error with Apikey API.",'1000grad-epaper');
echo $e->getMessage();
}
return false;
}
/**
* Funktionsabfrage
*/
public function getApikeyApiFunctions()
{
try {
$functions = $this->apikeyApiClient->__getFunctions();
return $functions;
} catch (SoapFault $e) {
_e("Error with Apikey API.",'1000grad-epaper');
echo $e->getMessage();
}
return false;
}
/**
* Registrierungsprozess schickt Daten an den ePaper Server, der verschickt dann Bestaetigungsmail
*/
public function getRegistrationCodeByEmail ($email, $text, $wordpress, $phpupload,
$phptime, $wordpresscode, $agb, $newsletter, $version_wordpress ,$version_php, $language)
{
$sMessage = NULL;
//debug test
//var_export($this->apikeyApiClient->__getFunctions()); die("zzz");
//var_export($this->apikeyApiClient->getRegistrationCodeByEmail($email, $text, $wordpress, $phpupload, $phptime, $wordpresscode, $agb, $newsletter, $version_wordpress ,$version_php, $language)); die("zzz");
try {
$res = $this->apikeyApiClient->getRegistrationCodeByEmail($email, $text, $wordpress, $phpupload,
$phptime, $wordpresscode, $agb, $newsletter, $version_wordpress ,$version_php, $language);
} catch (SoapFault $e) {
$sMessage = '
Error '.$e->getMessage().'';
if ($e->getMessage()=="(605) no valid email adress")
$sMessage.= __("
Email adress is not valid.",'1000grad-epaper');
if ($e->getMessage()=="(606) email already exists")
$sMessage.= __("
Email adress is already registered.",'1000grad-epaper');
$sMessage.= __("
Your Registration was not successful! Please try again.",'1000grad-epaper');
return array('error' => $sMessage);
}
$sMessage.= __("
Please have a look into your email inbox for confirmation code!",'1000grad-epaper');
return array('info' => $sMessage);
}
/**
* Abschluss des Registrierungsprozesses, Code wird eingegeben und APikey kommt
*/
public function sendCodeGetApikey($email, $code)
{
try {
$res = $this->apikeyApiClient->sendCodeGetApikey($email, $code);
return $res;
} catch (SoapFault $e) {
echo "
";
_e("Error with API.",'1000grad-epaper');
echo $e->getMessage();
}
return false;
}
/**
* Feedback Formular
*/
public function sendFeedback($email = NULL, $text = NULL, $more = NULL, $adminUrl = NULL, $phpupload = NULL, $phptime = NULL, $wpVersion = NULL, $phpVersion = NULL, $language = NULL, $plugin_version = NULL)
{
try {
$res = $this->apikeyApiClient->sendFeedback($email, $text, $more, $adminUrl, $phpupload, $phptime,
$wpVersion, $phpVersion, $language, $plugin_version);
return $res;
} catch (SoapFault $e) {
echo "
";
_e("Error with API.",'1000grad-epaper');
echo "
";
echo $e->getMessage();
}
return false;
}
/**
* Test Funktion zum Addieren weiterer Kanaele
*/
public function sendCodeGetMoreChannels($email, $code)
{
try {
$res = $this->apikeyApiClient->sendCodeGetMoreChannels($email, $code);
return $res;
} catch (SoapFault $e) {
// echo '