Load Facebook SDK

I'm trying to load Facebook SDL into my project but at the moment with no success

here is my bootstrap dispatcher:

$di->set('Facebook', function() use ($config) { return new Facebook(array( 'appId' => $config->facebook->appId, 'secret' => $config->facebook->secret, 'fileUpload' => $config->facebook->fileUpload, // optional 'allowSignedRequest' => $config->facebook->allowSignedRequest, )); });

the loader looks like this(in code is before dispatcher):

$loader->registerDirs( array( DIR . $config->application->controllersDir, DIR . $config->application->pluginsDir, DIR . '/app/library', DIR . $config->application->modelsDir, DIR . '/app/facebook', ) )->register();

where facebook files were put in /app/facebook, /app/library, /app/library/facebook. Itried multiple ways of including the files.

I called the facebook class like this: $user = $this->Facebook->getUser(); in IndexController and error which i received is: Fatal error: Class 'Facebook' not found in /mylongpath/public/index.php on line 142

I assume the problem is the loader by not sure what and why. Please help me with this situation.

The rest of project is "INVO" tutorial.



9.9k
edited May '14

How about:

$this->di->getService('Facebook')
$this->di['Facebook']

or

\Phalcon\DI::getDefault()->getService('Facebook')
\Phalcon\DI::getDefault()->['Facebook']