PHP-Xero icon indicating copy to clipboard operation
PHP-Xero copied to clipboard

Fatal error: Call to a member function get_name() on a non-object in /xero.php on line 784

Open unifonenz opened this issue 14 years ago • 4 comments

For some reason that is all i get whenever i try and call anything from the api. What am i doing wrong? I am running PHP version 5.2.4-2

unifonenz avatar Jul 28 '10 23:07 unifonenz

Could it be related to the issue discussed at http://github.com/thinktree/PHP-Xero/issues/closed#issue/1 ? Please check out that thread and let me know if this could be relevant to your case...

drpitman avatar Jul 29 '10 01:07 drpitman

It would be easier to prevent this issue if there was a public method to check the private variables in the Xero class: consumer, token, and signature_method. At the moment you can't detect whether you have a valid xero object or not before you start making queries (at least I can't get the constructor's return false statements).

Here's a patch I wrote:

diff --git a/xero.php b/xero.php
index 3afa43d..9782747 100644
--- a/xero.php
+++ b/xero.php
@@ -329,6 +329,13 @@ class Xero {
                return $this->$name();
        }
 
+       public function verify() {
+               if ( !is_object($this->consumer) || !is_object($this->token) || !is_object($thi
+                       return false;
+               }
+               return true;
+       }
+
 }
 
 //END Xero class
@@ -1317,4 +1324,4 @@ class ArrayToXML
     public static function isAssoc( $array ) {
         return (is_array($array) && 0 !== count(array_diff_key($array, array_keys(array_keys($
     }
-}
\ No newline at end of file
+}

I've tested it in cases where public cert is empty or not.

mradcliffe avatar Nov 02 '10 19:11 mradcliffe

tested this - necessary for the drupal module to do some checks of validity. please merge :-)

Br3nda avatar Mar 28 '11 22:03 Br3nda

was going to add the diff above but part of the message has been chopped off. are you able to re-post but maybe wrap the code?

unifonenz avatar Jul 20 '11 21:07 unifonenz