-1
  try {
            $userProfile = $facebook->api('/me');
        } catch(\FacebookApiException $e) {
            $user = null;
             echo ($e);
        }

        if ($user) {

            $needEdit = false;

            if (empty($userProfile['email'])) {
                $needEdit = true;
            }

            $username = \Str::slug($userProfile['name']);
            $username = str_replace([' ','.', '-'], ['','', ''], $username);



            $details = [
                'fullname' => $userProfile['first_name']. ' '. $userProfile['last_name'],
                'country' => '',
                'email_address' => (isset($userProfile['email'])) ? $userProfile['email'] : '',
                'password' => time(),
                'username' => $username,
                'auth' => 'facebook',
                'authId' => $userProfile['id'],
                'avatar' => 'https://graph.facebook.com/'.$userProfile['id'].'/picture?type=large'
            ];

           $data=$this->socialauthRepository->isAMember($details['auth'],$details['authId']);
          $emailExists=$this->socialauthRepository->emailExists($details['email_address']);
                    if(count($emailExists)==0){
                    if(count($data)==0){
                        \View::share('details', $details);
                        //$this->setTitle(trans('home.welcome-to-our-social-network'));
                    //  return $this->theme->view('home.index', ['users' => app('App\\Repositories\\UserRepository')->latestUsers(8)])->render();
                    return $this->render('user.home.index', ['posts' => $this->postRepository->dashboardlists('trendzoops'),'celeblist'=> $this->PageRepository->allceleblists()],         ['title' => $this->setTitle('The Trending Zoops')]);

                    }else{
                        return $this->socialauthRepository->register($details);
                    }
                }else{
                    return $this->socialauthRepository->loginwithemailid($emailExists);
                }   

        } else {
            $url = $facebook->getLoginUrl(['scope' => 'email','scope'=>'offline_access']);

            //return \Redirect::to($url);
        }

Facebook Object ( [sharedSessionID:protected] => [appId:protected] => *************** [appSecret:protected] => ********************* [user:protected] => 0 [signedRequest:protected] => [state:protected] => 60575776c07d60aa8d37d8b7f92ca454 [accessToken:protected] => *********************|********************* [fileUploadSupport:protected] => [trustForwarded:protected] => [allowSignedRequest:protected] => 1 ) 0OAuthException: An active access token must be used to query information about the current user.

I am using this app in laravel for past 1 and half year but suddenly I am getting $user = $facebook->getUser(); ie 0 . I have not changed anything in the facebook setting . As i am using artdarek/oauth-4-laravel and updated the composer also but still getting zero only I have search each and every question but have not found my answer

I am using PHP Version 5.6.25

1 Answers1

0

I think you may be using Facebook API v2.3 that was only available upto March 25, 2017. you need to upgrade you facebook api version. I prefer you to go for Facebook API v2.8 that i available upto October 2018.

For details of API Date you can check here - Facebook getuser Returning zero

Heemanshu Bhalla
  • 3,603
  • 1
  • 27
  • 53