PHP-Xero
PHP-Xero copied to clipboard
Fatal error: Call to a member function get_name() on a non-object in /xero.php on line 784
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
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...
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.
tested this - necessary for the drupal module to do some checks of validity. please merge :-)
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?