페이스북 로그인 안되시는 분들 참고해주세요. > 자유게시판

자유게시판

페이스북 로그인 안되시는 분들 참고해주세요. 정보

페이스북 로그인 안되시는 분들 참고해주세요.

본문

facebook api v2.2 이 종료가 되면서    

/oauth/access_token 의 리턴값이 query_string 형태에서 json 형태 값으로 변경되었습니다.

 

/plugin/sns/facebook/src/base_facebook.php 중  

parse_str() 대신 json_decode를 이용해주시면 됩니다.  

 


  protected function getAccessTokenFromCode($code, $redirect_uri = null) {

    if (empty($code)) {
      return false;
    }

    if ($redirect_uri === null) {
      $redirect_uri = $this->getCurrentUrl();
    }

    try {
      // need to circumvent json_decode by calling _oauthRequest
      // directly, since response isn't JSON format.
      $access_token_response =
        $this->_oauthRequest(
          $this->getUrl('graph', '/oauth/access_token'),
          $params = array('client_id' => $this->getAppId(),
                          'client_secret' => $this->getAppSecret(),
                          'redirect_uri' => $redirect_uri,
                          'code' => $code));
    } catch (FacebookApiException $e) {
      // most likely that user very recently revoked authorization.
      // In any event, we don't have an access token, so say so.
      return false;
    }

    if (empty($access_token_response)) {
      return false;
    }

 
    $response_params = json_decode($access_token_response, true);
    //$response_params = array();
    //parse_str($access_token_response, $response_params);

    if (!isset($response_params['access_token'])) {
      return false;
    }

    $fb_access_token_expires = strtotime(G5_TIME_YMDHIS)+$response_params['expires'];
    $this->setPersistentData('access_token_expires', $fb_access_token_expires);

    return $response_params['access_token'];
  } 

   

 

 

추천
5
  • 복사

댓글 7개

© SIRSOFT
현재 페이지 제일 처음으로