Call to undefined method FacebookRestClient::set_user()
| Project: | Drupal for Facebook |
| Version: | 6.x-2.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Jump to:
Practically brand new empty drupal 6.11 install, dropped the 6.x-2.x-dev in place.
Followed the instructions in the README.txt up through
Go to Create Content >> Facebook Application. Use the apikey and ...
Form filled in, but on save this was the only thing generated:
Fatal error: Call to undefined method FacebookRestClient::set_user() in /usr/www/users/stout/resolve_ticode.com/teamtracker/sites/all/modules/fb/facebook-platform/php/facebook.php on line 81
I got the facebook-platform.tar.gz from: http://svn.facebook.com/svnroot/platform/clients/packages/facebook-platf...
And i HAVE notices the numerous warnings about PHP4 vs PHP5 in the manual. still the link above contained facebookapi_php5_restlib.php
If the problem ISN'T the php5 vs php4, then I think it may be some sort of ordering thing, because in the fresh version of facebook-platform/php/facebookapi_php5_restlib.php, the second function on line 126 is clearly the "missing" set_user().
Let me know how I can help debug this.

#1
Some more information added the following lines to facebook-platform/php/facebook.php just before the error throwing line 81:
<?php
if (!$this->api_client)
{
print "<h2>api_client is null</h2>";
exit();
}
if (method_exists($this->api_client, 'set_user'))
{
print "<h2>api_client->set_user is not defined</h2>";
exit();
}
print "<h2>api_client->set_user should be defined</h2>";
$this->api_client->set_user($defaultUser);
?>
suprisingly, the last print was output prior to the same fatal error.
Could this be something weird from the facebook side?
#2
In my copy I see set_user defined. You have to use PHP5. PHP4 will not do.
I don't know what the problem is but you seem to be the only one (or first) to report it.
#3
Using PHP5, but my question about PHP4 was due to all the docs talking about PHP4, we use 5 on all my servers.
I've moved to another project for a few weeks, I'll be happy to go into details in a few weeks on this.
#4
Had a spare moment,
public function __construct($api_key, $secret, $session_key=null, $user=null)
<?phpif ($user)
{
$this->set_user($user);
}
?>
Final form:
<?php
public function __construct($api_key, $secret, $generate_session_secret=false) {
$this->api_key = $api_key;
$this->secret = $secret;
$this->generate_session_secret = $generate_session_secret;
$this->validate_fb_params();
// Set the default user id for methods that allow the caller to
// pass an explicit uid instead of using a session key.
$defaultUser = null;
if ($this->user) {
$defaultUser = $this->user;
} else if ($this->profile_user) {
$defaultUser = $this->profile_user;
} else if ($this->canvas_user) {
$defaultUser = $this->canvas_user;
}
$this->api_client = new FacebookRestClient($api_key, $secret, null, $defaultUser);
/* $this->api_client->set_user($defaultUser); */
if (isset($this->fb_params['friends'])) {
$this->api_client->friends_list = explode(',', $this->fb_params['friends']);
}
if (isset($this->fb_params['added'])) {
$this->api_client->added = $this->fb_params['added'];
}
if (isset($this->fb_params['canvas_user'])) {
$this->api_client->canvas_user = $this->fb_params['canvas_user'];
}
}
?>
Apparently there's some sort of scoping issue in the facebook library, as if public function set_user was somehow private. Rather than solve their problem, I just hacked around it.
With the above changes I could make the first facebook application save.
It still churns my butter that I had to hack the FB stuff, and that I'm the only one (so-far) to hit this snag, but if it works, I guess we can't complain too much.
#5
Yeah this sounds weird. Sure you have the latest client libs? There's no older copy or some other facebook module around?
You could look this up on facebook's forums. If you like being ignored, you could submit an issue to their bug tracker. Until it bites me, I don't have time to investigate. But thanks for posting details.
#6
Thank you so much for posting a work around! I was getting the same error and your changes did the trick.
#7
I'm using the brand new library, and getting this problem ... there maybe be another copy of the same library, but they're all in different parts of the directory tree, and I use the sites/default/settings.php option to force fb to use the library in the sites/all/modules/fb/facebook-platform/php/
with:
<?php
$conf['fb_api_file'] = 'sites/all/modules/fb/facebook-platform/php/facebook.php';
require_once "sites/all/modules/fb/fb_settings.inc";
?>
So it may be worthwhile to post a link to this issue somewhere in the module fb docs?? In case more than librarysarah and I run into this.
@sarah, I'm glad my hacking was useful. Too bad it's likely to be ignored by the FB developers :(
#8
Dang, messed up the title LOL
#9
The idea of the $conf['fb_api_file'] setting is so that if you have to use two modules which both need the facebook client libs, you can install them in just one place and tell Drupal for Facebook where to find them. So if you have some other module which includes those libs, use $conf['fb_api_file'] to find them in that place.
Two copies of those libs is a bad idea. It might be the cause of this problem.
Also I'm curious why you need an additional facebook module. Which one, and what feature are you looking for that the fb modules do not provide?