Question

I'm trying to set up a system to auto-login a user into my site if they are already connected to facebook in another tab and I got this error message from Zend Framework:

Message: Method "getUserFromAvailableData" does not exist and was not trapped in __call() 

I've already downloaded the Facebook php API from https://github.com/facebook/facebook-php-sdk and uploaded it to my server, and the method does indeed exist, on line 463 of the base-facebook.php file. Here's where I'm calling the API, if it makes any difference.

require_once(BASE_PATH . "/library/facebook-php/src/facebook.php");
$fbid = Facebook::getUser();

What could be causing this error? Am I doing something wrong on my end?

Was it helpful?

Solution

On the developer's site page for the getUser function, here, they show the method as being static. They use the header Facebook::getUser(), but if you look at the source code in base-facebook.php you'll find this line:

return $this->user = $this->getUserFromAvailableData();

Even though they show it as being static in the documentation, or at least make it look like it is, you can see here that it is actually dependent on there first being a facebook instance, and that the reason it couldn't find the method in my code is that I didn't create one. As soon as I created a facebook instance the error message disappeared.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top