skip to Main Content

Here is my code to get the user information and verify it from my database.

<?php
require_once ("autoload.php");
include_once 'config.php';

$facebook = new FacebookFacebook(array(
      'app_id'  => FACEBOOK_APP_ID,
      'app_id'  => FACEBOOK_APP_ID,
      'cookie' => true,
));
$parm = array(
    'scope' => 'read_stream, friends_likes',
    'redirect_uri' => 'https://apps.facebook.com/isensor/'
);

$uid = $facebook->getUser();

if($uid)
{
try {

    $fbme = $facebook->api('/me');
    $access_token = $facebook->getAccessToken();
    }
catch (FacebookApiException $e) 
    {
    error_log($e);
    $user = null;

    }
}

I think facebook has removed the getUser() function. Can anyone please tell me how should I fix this?

2

Answers


  1. The Facebook docs (here) refer to getGraphUser()

    Login or Signup to reply.
  2. You should use getGraphUser() because getUser() was deprecated on SDK v.3.2.3

    $me = $response->getGraphUser();
    echo 'Logged in as ' . $me->getName();
    

    Take a look at Facebook Graph SDK

    I hope this helps.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search