-
-
Save holic940817/9d20db1a17e53502aa84 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><!--JSP 기본적 페이지 세팅--> | |
<%@ page import="com.common.util.*" %><!-- 회사에서 사용하는 유틸 패키지 --> | |
<% | |
String appId="1443259392553103";//페이스북 개발자 페이지에 존재하는 앱 아이디 | |
String secretCode = "9ff3053af97bdfa4207f76a319adb0e5";//페이스북 개발자 페이지에 존재하는 시크릿코드 | |
String code = Fn.toString(request,"code");//url로 받은 code의 값 (https://~~~~~?code=****) **** 이부분을 code라는 변수에 저장 | |
String redirectUrl = "http://localhost:8080/ApiDev/open_content/facebook/token/get_token.jsp";//토큰을 다시 받을 페이지 | |
String permission = "user_status";//토큰 퍼미션 | |
String tokenUrl="https://graph.facebook.com/oauth/access_token?client_id="+appId +"&redirect_uri="+redirectUrl +"&client_secret="+secretCode +"&code="+code +"";//토큰을 받는 url | |
String tokenStep1 = Fn.getUrl_doc_read(tokenUrl, "UTF-8");//tokenUrl의 페이지 컨텐츠를 UTF-8형식으로 읽어들이는 유틸 | |
String tokenStep2 = Fn.replaceAll(tokenStep1, "access_token=", "");//tokenStep1의 변수에 담긴 값에서 access_token=이라는 글자를 지워버림 | |
String tokenStep3 = "&"+Fn.substringAfter(tokenStep2, "&");//tokenStep2의 변수에 담긴 값에서 &를 포함한 뒤의 문자를 tokenStep3에 담기 | |
String tokenStep4 = Fn.replaceAll(tokenStep2, tokenStep3, "");//tokenStep2의 변수에 감긴 값에서 tokenStep3의 값을 지워버림 | |
%> | |
<%if(tokenStep4.length()>0){//만약 tokenStep4의 길이가 0보다 크다면(토큰을 받아왔다면)%> | |
<textarea rows="8" cols="30"><%=tokenStep4 %></textarea><!-- 화면에 표출 --> | |
<%}else{//그렇지 않다면%> | |
<a href="https://www.facebook.com/dialog/oauth?client_id=<%=appId %>&redirect_uri=<%=redirectUrl %>&scope=<%=permission%>"><input type="button" value="Get Code" /></a> | |
<!-- 토큰을 받기전 필요한 코드값을 받는 페이지로 이동 하는 버튼을 화면에 표출--> | |
<%}%> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment