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);

}

 

 

?>

Link to comment
Share on other sites

  • 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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.