PHP:获取错误消息在wordpress中调用未定义的方法soap_call

时间:2013-05-16 05:34:30

标签: php apache curl

当我想知道cron作业失败的原因时,我在服务器的错误日志中发现了一条非常奇怪的错误消息:

  

PHP致命错误:在第19行的wp-content / plugins / lead-management-tool / class.leads_360_api.php中调用未定义的方法CEmailReader::soap_call()

请查看指定源文件的完整代码:正如您所看到的,那里没有引用所提到的类(尽管该类存在于其他地方)。

在这台服务器上发生了一些非常奇怪的事情,我不知道在哪里寻找错误。

请注意,此错误仅在此服务器上发生,并且仅在通过cron作业curl调用执行上述过程时发生。所有其他非常相似的cron作业都可以正常工作,这个函数在从管理员执行时非常有效。

感谢您提前付出的努力! (现在请忽略糟糕的编码技术)

<?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;     
    }
}
?>

0 个答案:

没有答案