네이버 API는 무조건 그누보드5부터인가요?

네이버 API는 무조건 그누보드5부터인가요?

QA

네이버 API는 무조건 그누보드5부터인가요?

본문

그누보드4에서는 절대로 네이버로 로그인하기 API를 적용할 수 없는건가요?

 

 

이 질문에 댓글 쓰기 :

답변 3

적용할수 있습니다. 다만 그누4에서는 적용이안되서 따로 적용시켜야 합니다. 

define( NAVER_OAUTH_URL, "https://nid.naver.com/oauth2.0/" );
define( NAVER_SESSION_NAME, "NHN_SESSION" );
@session_start();


class Naver{

private $tokenDatas = array();

private $access_token = ''; // oauth 엑세스 토큰
private $refresh_token = ''; // oauth 갱신 토큰
private $access_token_type = ''; // oauth 토큰 타입
private $access_token_expire = ''; // oauth 토큰 만료


private $client_id = ''; // 네이버에서 발급받은 클라이언트 아이디
private $client_secret = ''; // 네이버에서 발급받은 클라이언트 시크릿키

private $returnURL = ''; // 콜백 받을 URL ( 네이버에 등록된 콜백 URI가 우선됨)
private $state = ''; // 네이버 명세에 필요한 검증 키 (현재 버전 라이브러리에서 미검증)


private $loginMode = 'request'; // 라이브러리 작동 상태

private $returnCode = ''; // 네이버에서 리턴 받은 승인 코드
private $returnState = ''; // 네이버에서 리턴 받은 검증 코드

private $nhnConnectState = false;


// action options
private $autoClose = true;
private $showLogout = true;

private $curl = NULL;
private $refreshCount = 1;  // 토큰 만료시 갱신시도 횟수

private $drawOptions = array( "type" => "normal", "width" => "200" );

function __construct($argv = array()) {

if  ( ! in_array  ('curl', get_loaded_extensions())) {
echo 'curl required';
return false;
}


if($argv['CLIENT_ID']){
$this->client_id = trim($argv['CLIENT_ID']);
}

if($argv['CLIENT_SECRET']){
$this->client_secret = trim($argv['CLIENT_SECRET']);
}

if($argv['RETURN_URL']){
$this->returnURL = trim(urlencode($argv['RETURN_URL']));
}

if($argv['AUTO_CLOSE'] == false){
$this->autoClose = false;
}

if($argv['SHOW_LOGOUT'] == false){
$this->showLogout = false;
}






$this->loadSession();

if(isset($_GET['nhnMode']) && $_GET['nhnMode'] != ''){
$this->loginMode = 'logout';
$this->logout();
}

if($this->getConnectState() == false){
$this->generate_state();

if($_GET['state'] && $_GET['code']){
$this->loginMode = 'request_token';
$this->returnCode = $_GET['code'];
$this->returnState = $_GET['state'];

$this->_getAccessToken();

}
}
}



function login($options = array()){


if(isset($options['type'])){
$this->drawOptions['type'] = $options['type'];
}

if(isset($options['width'])){
$this->drawOptions['width'] = $options['width'];
}



if($this->loginMode == 'request' && (!$this->getConnectState()) || !$this->showLogout){
echo '<a href="javascript:loginNaver();"><img src="https://www.eventmaker.kr/open/idn/naver_login.png" alt="네이버 아이디로 로그인" width="'.$this->drawOptions['width'].'"></a>';
echo '
<script>
function loginNaver(){
var win = window.open(\''.NAVER_OAUTH_URL.'authorize?client_id='.$this->client_id.'&response_type=code&redirect_uri='.$this->returnURL.'&state='.$this->state.'\', \'네이버 아이디로 로그인\',\'width=320, height=480, toolbar=no, location=no\');

var timer = setInterval(function() {
if(win.closed) {
window.location.reload();
clearInterval(timer);
}
}, 500);
}
</script>
';
}else if($this->getConnectState()){
if($this->showLogout){
echo '<a href="http://'.$_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"].'?nhnMode=logout"><img src="https://www.eventmake



이걸 참고해서 하고 있습니다!!!
이걸 참고해서도 가능할까요?

api 는 그누보드 와 관계 없이 연동하실수 있습니다.

 

다만 그누보드를 잘아는 회원이다보니 그누보드에 적용하려면 아무래도 좀더 용이 하게 작업이

가능하지 않나 생각됩니다.~

 

답변을 작성하시기 전에 로그인 해주세요.
전체 123,969 | RSS
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT