2017-03-29 24 views
-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的對象(信息[sharedSessionID:保護] => [APPID:保護] => ******* ******** [appSecret:protected] => ********************* [user:protected] => 0 [signedRequest:protected] = > [state:protected] => 60575776c07d60aa8d37d8b7f92ca454 [accessToken:protected] => ********************* | ************ ********* [fileUploadSupport:protected] => [trustForwarded:protected] => [allowSignedRequest:protected] => 1)0OAuthException:必須使用活動訪問令牌來查詢有關當前用戶的信息。的Facebook的getUser返回0和活性訪問令牌必須用於查詢有關當前用戶

我在拉拉維爾使用這個應用程序過去1年半,但突然間我得到$ user = $ facebook-> getUser();即0。我沒有改變facebook設置中的任何內容。由於我使用artdarek/OAuth的4 laravel和更新的作曲家也 但仍然得到零隻有我有搜索每一個問題,但還沒有找到我的答案

我使用的PHP版本25年6月5日

回答

0

我想你可能正在使用僅在2017年3月25日之前可用的Facebook API v2.3。你需要升級你的facebook api版本。我更喜歡你去Facebook API v2.8,我可用到2018年10月。

有關API日期的詳細信息,你可以在這裏查看 - Facebook getuser Returning zero

相關問題