0

I am trying to get the new facebook php sdk setup on my site. I'm running the latest stable version of php. I have never messed with namespaces before. Can someone tell me what I'm doing wrong?

I get this error

Fatal error: Class 'FacebookSession' not found in

When I run this code

FacebookSession::setDefaultApplication( 'xxx','yyy' );

.....

// path of these files have changes
require_once( '/var/www/vhosts/server/site/lib/fb/Facebook/HttpClients/FacebookHttpable.php' );
require_once( '/var/www/vhosts/server/site/lib/fb/Facebook/HttpClients/FacebookCurl.php' );
require_once( '/var/www/vhosts/server/site/lib/fb/Facebook/HttpClients/FacebookCurlHttpClient.php' );

// other files remain the same
require_once( '/var/www/vhosts/server/site/lib/fb/Facebook/FacebookSession.php' );
require_once( '/var/www/vhosts/server/site/lib/fb/Facebook/FacebookRedirectLoginHelper.php' );
require_once( '/var/www/vhosts/server/site/lib/fb/Facebook/FacebookRequest.php' );
require_once( '/var/www/vhosts/server/site/lib/fb/Facebook/FacebookResponse.php' );
require_once( '/var/www/vhosts/server/site/lib/fb/Facebook/FacebookSDKException.php' );
require_once( '/var/www/vhosts/server/site/lib/fb/Facebook/FacebookRequestException.php' );
require_once( '/var/www/vhosts/server/site/lib/fb/Facebook/FacebookOtherException.php' );
require_once( '/var/www/vhosts/server/site/lib/fb/Facebook/FacebookAuthorizationException.php' );
require_once( '/var/www/vhosts/server/site/lib/fb/Facebook/GraphObject.php' );
require_once( '/var/www/vhosts/server/site/lib/fb/Facebook/GraphSessionInfo.php' );

// path of these files have changes
use Facebook\HttpClients\FacebookHttpable;
use Facebook\HttpClients\FacebookCurl;
use Facebook\HttpClients\FacebookCurlHttpClient;

use Facebook\FacebookSession;
use Facebook\FacebookRedirectLoginHelper;
use Facebook\FacebookRequest;
use Facebook\FacebookResponse;
use Facebook\FacebookSDKException;
use Facebook\FacebookRequestException;
use Facebook\FacebookOtherException;
use Facebook\FacebookAuthorizationException;
use Facebook\GraphObject;
use Facebook\GraphSessionInfo;
Clint C.
  • 678
  • 13
  • 31
  • You probably need composer to handle autoload and dependency for the SDK. – Rahil Wazir Jun 16 '14 at 19:24
  • I'm reading about composer now. Why would it make a difference as compared to having the files on my site? Sorry I'm new to this – Clint C. Jun 16 '14 at 19:35
  • Would my autoloader for my other classes break it? function __autoload($class_name) { if(file_exists(ROOT.LIBRARY . $class_name . '/class.' .$class_name . '.php')) { require_once ROOT.LIBRARY . $class_name . '/class.' .$class_name . '.php'; } } – Clint C. Jun 16 '14 at 19:36
  • Maybe no go ahead and try. – Rahil Wazir Jun 17 '14 at 10:37
  • Is there a way to specify the php folder to install it to? – Clint C. Jun 19 '14 at 15:54
  • possible duplicate of [Facebook SDK v4 for PHP Minimal Example](http://stackoverflow.com/questions/23413854/facebook-sdk-v4-for-php-minimal-example) – Rajesh Ujade Sep 09 '14 at 05:05

2 Answers2

1

You don't need to use the full path to the Facebook SDK unless you are trying to access it from a totally different location. You should be able to access it using a relative path, like lib/fb/Facebook/GraphSessionInfo.php, assuming your index.php file is located in the site folder.

Also, try doing the following and see if you still get an error:

Facebook\FacebookSession::setDefaultApplication( 'xxx','yyy' );
Niraj Shah
  • 15,087
  • 3
  • 41
  • 60
0

Problem was due to PEAR being installed on the server for email. The include path in php settings was modified.

I actually removed PEAR, set PHP back to it's default include path and switched email to swiftmailer.

Clint C.
  • 678
  • 13
  • 31