facebook->getUser() returning 0

前端 未结 5 1441
天涯浪人
天涯浪人 2021-01-16 04:36

Whenever I try to login a prompt opens asking for the basic permissions, after that its being redirected to my redirect_uri with an URL

=\">http://loc

5条回答
  •  挽巷
    挽巷 (楼主)
    2021-01-16 04:49

    if someone is still banging their head over this here is what is wrong now. I was hired to fix this mess!

    1. Check App domain in fb panel , must match with the domain where your app is.

    2. edit base_facebook.php find:

      public function getAccessToken() {

      if ($this->accessToken !== null) {
        // we've done this already and cached it.  Just return.
        return $this->accessToken;
      }
      
      // first establish access token to be the application
      // access token, in case we navigate to the /oauth/access_token
      // endpoint, where SOME access token is required.
      $getApplicationAccessToken = $this->getApplicationAccessToken();
      $this->setAccessToken($getApplicationAccessToken);
      $user_access_token = $this->getUserAccessToken();
      if ($user_access_token) {
        $this->setAccessToken($user_access_token);
      }
      return $this->accessToken;
      

      }

    to::

      public function getAccessToken() {
    
        if ($this->accessToken !== null) {
          // we've done this already and cached it.  Just return.
          return $this->accessToken;
        }
    
        // first establish access token to be the application
        // access token, in case we navigate to the /oauth/access_token
        // endpoint, where SOME access token is required.
        $getApplicationAccessToken = $this->getApplicationAccessToken();
        $this->setAccessToken($getApplicationAccessToken);
        $user_access_token = $this->getUserAccessToken();
        if ($user_access_token) {
          //$this->setAccessToken($user_access_token);
        $this->accessToken = $user_access_token; //edit; msolution
        }
        return $this->accessToken;
      }
    
    1. Next find the function: getAccessTokenFromCode()

    find the line:

    parse_str($access_token_response, $response_params); 
    

    replace it with:

    //parse_str($access_token_response, $response_params); //edit:: msolution;;
    $response_params = json_decode($access_token_response, true );
    

    commenting the original and adding json_decode

    thats it!

提交回复
热议问题