Jump to content

Fatal error: Call to a member function call() on a non-object


rowiebiz

Recommended Posts

Hi, I have a code below and I keep on getting the error "Fatal error: Call to a member function call() on a non-object in on line 29". Can someone help me please to fix and solve the error. Please help.

 

The line 29 here is the section that say

 

$this->apiresult =  $this->apiclient->call($apimethodname);

 

but I think I already instantiated the $this->apiclient via the constructor

 

Please Help.

 

<?php

// includes nusoap class

require_once('lib/nusoap.php');

class dashcs

{

public $apiresult = null;

public $apierror = null;

public $apiclient = '';

 

function __constuct(&$apiclient)

{

// instantiate the web service api

$this->apiclient = $apiclient;

$this->apiclient->setCredentials("rrusdf","959dfde3","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.dsdff.com/dash-api/soap/emergencyprovisioning/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);

}

 

 

?>

  • 2 weeks later...

You're passing the constructor argument by reference, which is unnecessary because you're then storing it as an attribute in the class.  This may also be causing the element to fall out of scope though I don't know for sure.  Try passing the constructor argument by value instead.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.