Call to a member function call() on a non-object
Posted: Thu Dec 30, 2010 4:52 pm
Hi, I have a script below and I always get the error "Call to a member function call() on a non-object". Can someone help me out how to fix / to deal with this. Please help. Thanks.
<?php
// includes nusoap class
require_once('lib/nusoap.php');
class dashcs
{
public $apiresult = null;
public $apierror = null;
public $apiclient = null;
function __constuct($apiclient)
{
// instantiate the web service api
$this->apiclient = $apiclient;
$this->apiclient->setCredentials("rreffo","95dff6e3","basic");
$this->apierror = $this->apiclient->getError();
if($this->apierror)
{
return false;
}else{
return true;
}
}
//
function dashCallMethod($apimethodname = null,$apiparameters= null)
{
// call the method of the service
if($apiparameters == null || $apiparameters == ''){
$this->apiresult = $this->apiclient->call($apimethodname);
}else{
$this->apiresult = $this->apiclient->call($apimethodname,$apiparameters);
}
if($this->apiclient->fault){
// check for fault
return false;
}else{
// Check for errors
$this->apierror = $this->apiclient->getError();
if ($this->apierror) {
return false;
}else{
return true;
}
}
}
}
// Create objects
$apiclient = new nusoap_client('https://service.sdfdff.com/dash-api/soa ... ng/v1?wsdl', true);
$dash_api = new dashcs($apiclient);
if(!$dash_api)
{
echo $dash_api->apierror;
}
// check first the authentication
if($dash_api->dashCallMethod('getAuthenticationCheck'))
{
echo "API Error: $apierror";
print_r($dash_api->apiresult);
}else{
print_r($dash_api->apiresult);
}
?>
<?php
// includes nusoap class
require_once('lib/nusoap.php');
class dashcs
{
public $apiresult = null;
public $apierror = null;
public $apiclient = null;
function __constuct($apiclient)
{
// instantiate the web service api
$this->apiclient = $apiclient;
$this->apiclient->setCredentials("rreffo","95dff6e3","basic");
$this->apierror = $this->apiclient->getError();
if($this->apierror)
{
return false;
}else{
return true;
}
}
//
function dashCallMethod($apimethodname = null,$apiparameters= null)
{
// call the method of the service
if($apiparameters == null || $apiparameters == ''){
$this->apiresult = $this->apiclient->call($apimethodname);
}else{
$this->apiresult = $this->apiclient->call($apimethodname,$apiparameters);
}
if($this->apiclient->fault){
// check for fault
return false;
}else{
// Check for errors
$this->apierror = $this->apiclient->getError();
if ($this->apierror) {
return false;
}else{
return true;
}
}
}
}
// Create objects
$apiclient = new nusoap_client('https://service.sdfdff.com/dash-api/soa ... ng/v1?wsdl', true);
$dash_api = new dashcs($apiclient);
if(!$dash_api)
{
echo $dash_api->apierror;
}
// check first the authentication
if($dash_api->dashCallMethod('getAuthenticationCheck'))
{
echo "API Error: $apierror";
print_r($dash_api->apiresult);
}else{
print_r($dash_api->apiresult);
}
?>