I’m new to Facebook API and I’m currently trying to get the user friend list in a variable.
This is the code, I have within my controller:
$accept = $this->isAcceptApp($this->app_secret);
$this->view->accept = $accept;
$facebook = new Facebook(array(
'appId' => $this->app_id,
'secret' => $this->app_secret,
'cookie' => true,
));
$session = $facebook->getSession();
if ($session) {
$friends = $facebook->api('/me/friends');
I have this on the top of my Controller:
require_once("facebook.php");
Well one thing I can see is a mistake right away. Quite a while ago the SDK was altered and the login process slightly changed…
This is what it should look like now –
Notice that
getSession()is not used. Use thegetUser()function instead.You can get your hands on an updated version of the SDK from github (currently v.3.2.2).