webtechnick / CakePHP-Facebook-Plugin

CakePHP Facebook Plugin
http://facebook.webtechnick.com
445 stars 138 forks source link

Fatal Error (1): Call to a member function share() on a non-object in #160

Closed ava007 closed 8 years ago

ava007 commented 10 years ago

Hi,

after installing CakePHP-Facebook-Plugin, I'm getting the following error message:

Fatal Error (1): Call to a member function share() on a non-object in......

Here is the Controller action:

App::uses('AppController', 'Controller'); class DsController extends AppController { public $components = array('RequestHandler','Session','OAuthConsumer'); public $helpers = array('Facebook.Facebook');

public function fb_send() { $this->autoRender=false; $this->Facebook->share('http://www.locavores.co'); $this->log('Plugins loaded: ' . print_r(App::objects('plugin'),true) . "\nHelpers:". print_r($this->helpers,true) );

}

Output: 2014-05-23 15:42:09 E: Plugins loaded: Array ( [0] => DebugKit [1] => Facebook )

Helpers:Array ( [0] => Facebook.Facebook )

Versions: php 5.5.12 Cakephp 2.5.1

Any hints or ideas to solve this issue? Thanks, André

scrx commented 10 years ago

You cant use your Helper in your Controller actions instead use: echo $this->Facebook->share('http://www.locavores.co'); in your name_of_the_view.ctp and thats all.