we have a very strange error message I found in the server's error log when I wanted to see why a cron job fails:
PHP Fatal error: Call to undefined method
CEmailReader::soap_call()
in wp-content/plugins/lead-management-tool/class.leads_360_api.php on line 19
please see the complete code of the indicated source file: as you can see there is no reference to the mentioned class there (though the class exists elsewhere).
Something very strange happens in this server, and I have no idea where to look for the mistake.
Note that this error happens only on this server, and occures only when the mentioned procedure is executed by a cron job curl call. All other very similar cron jobs work fine, and this function works perfect when executed from an admin gui.
Thanks for your effort in advance! (and please ignore the poor coding technique for now)
<?php
if (!class_exists('nusoap_client')) require('nusoap/lib/nusoap.php');
class leads_360_api{
var $params;
const WSDL_ENDPOINT = 'https://service.leads360.com/ClientService.asmx';
const SOAP_ENDPOINT = 'https://service.leads360.com/';
/**
* constructor
* $username api username
* $password api password
* */
function __construct($username,$password){
$this->params['username'] = $username;
$this->params['password'] = $password;
}
function GetLeadsByEmail($email) {
$this->params['email'] = trim($email);
return $this->soap_call('GetLeadsByEmail'); // this is line 19
}
function GetActionTypes(){
return $this->soap_call('GetActionTypes');
}
function AddLeadAction($leadId,$actionTypeId,$actionNote){
$this->params['leadId'] = $leadId;
$this->params['actionTypeId'] = $actionTypeId;
$this->params['actionNote'] = $actionNote;
return $this->soap_call('AddLeadAction');
}
private function soap_call($soap_action){
$client = new nusoap_client(self::WSDL_ENDPOINT,'wsdl');
$client->soap_defencoding = 'UTF-8';
$err = $client->getError();
if ($err) {
echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->getDebug(), ENT_QUOTES) . '</pre>';
exit();
}
$soapval = "
<$soap_action xmlns='https://service.leads360.com'>";
foreach ($this->params as $name => $value) {
$soapval .= "<$name>$value</$name>";
}
$soapval .= "</$soap_action>";
$soapmsg = $client->serializeEnvelope($soapval);
$soapreturn = $client->send($soapmsg, self::SOAP_ENDPOINT.$soap_action);
// $soapreturn = $client->call('GetLeadsByEmail',$params);
$retval = array();
if ($client->fault) {
$retval['fault'] = true; // invalid soap body
} else {
$err = $client->getError();
if ($err) {
$retval['error'] = $err;
}
}
$retval['return'] = $soapreturn;
$retval['request'] = $client->request;
$retval['response'] =$client->response;
$retval['debug'] = $client->getDebug();
return $retval;
}
}
?>