티스토리 뷰

API/Google 구글

프로필 띄우기...

KIMSG 2017. 7. 21. 15:46
스크립트 파일 
 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
function onSignIn(googleUser) {
       var profile = googleUser.getBasicProfile();
       console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
       console.log('Name: ' + profile.getName());
       console.log('Image URL: ' + profile.getImageUrl());
       console.log('Email: ' + profile.getEmail());
 
       var sgTestDiv = "";
       sgTestDiv = "<img src="+profile.getImageUrl()+"><div>"+profile.getName()+"</div>";
       document.getElementById("sgTest").innerHTML = sgTestDiv;
     }
 
  window.___gcfg = {
    lang: 'ko',
    parsetags: 'onload'
  };
 
  function signOut() {
    var auth2 = gapi.auth2.getAuthInstance();
    auth2.signOut().then(function () {
      console.log('User signed out.');
 
      $("#sgTest").remove();
    });
  }
cs




하고 밑에 html 내용


1
2
3
4
5
<div class="g-signin2" data-onsuccess="onSignIn"></div>
   <div id="sgTest"> </div>
 <a href="#" onclick="signOut();">Sign out</a>
<div class="g-plus" data-action="share" ></div>
 
cs




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
하고 프로필 조금 커스터 마이징
 
 
function onSignIn(googleUser) {
       var profile = googleUser.getBasicProfile();
       console.log('ID: ' + profile.getId()); // Do not send to your backend! Use an ID token instead.
       console.log('Name: ' + profile.getName());
       console.log('Image URL: ' + profile.getImageUrl());
       console.log('Email: ' + profile.getEmail());
      
       var sgTestDiv = "";
       sgTestDiv = "<img src="+profile.getImageUrl()+"><div>"+profile.getName()+"</div>";
       document.getElementById("sgTest").innerHTML = sgTestDiv;
      
       var signOutTest = "";
       signOutTest = "<a href="+"#"+" onclick="+"signOut();"+">Sign out</a>";
       document.getElementById("sgTestSignOut").innerHTML = signOutTest;
      
       var sgTestShareDiv = "";
       sgTestShareDiv = "<div class="+"g-plus"+" data-action="+"share"+" ></div>";
       document.getElementById("sgTestShare").innerHTML = sgTestShareDiv;
      
     }
  window.___gcfg = {
    lang: 'ko',
    parsetags: 'onload'
  };
  function signOut() {
    var auth2 = gapi.auth2.getAuthInstance();
    auth2.signOut().then(function () {
      console.log('User signed out.');
     
      $("#sgTest").remove();
      $("#sgTestSignOut").remove();
    });
  }
 
cs


'API > Google 구글' 카테고리의 다른 글

언어 바꾸기  (0) 2017.07.21
구글 지도 마커 드래그 마지막값 가져오기  (0) 2017.07.21
구글 지도 쓰기  (0) 2017.07.21
구글 플러스에 공유 시켜보기... (google plus)  (0) 2017.07.21
구글 로그인 사용법  (0) 2017.07.21
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함