<h2>วิà¸à¸µà¸à¸³à¸£à¸°à¸à¸ Login à¸à¹à¸§à¸¢ Google Plus Javascript API</h2>
<p><strong>วิà¸à¸µà¸à¸³à¸£à¸°à¸à¸ Login à¸à¹à¸§à¸¢ Google Plus Javascript API</strong><br />
à¸à¸±à¸à¸à¸¸à¸à¸±à¸à¸à¸²à¸£à¸à¸±à¸à¸à¸²à¹à¸§à¹à¸à¹à¸à¸à¹à¸à¸µà¹à¸¡à¸µà¸£à¸°à¸à¸à¸ªà¸¡à¸²à¸à¸´à¸ à¹à¸£à¸²à¸¡à¸±à¸à¸à¸°à¹à¸«à¹à¸à¸à¸¸à¹à¸¡à¹à¸à¹à¸²à¸ªà¸¹à¹à¸£à¸°à¸à¸à¹à¸à¸´à¹à¸¡à¹à¸à¹à¸²à¸¡à¸²à¸à¸µà¸à¸«à¸à¸¶à¹à¸à¸à¸¸à¹à¸¡ à¸à¸·à¸à¸à¸²à¸£à¹à¸à¹à¸²à¸ªà¸¹à¹à¸£à¸°à¸à¸à¸à¹à¸§à¸¢ Facebook Account à¸à¸²à¸£à¹à¸à¹à¸²à¸ªà¸¹à¹à¸£à¸°à¸à¸à¹à¸à¸¢à¸à¸²à¸¨à¸±à¸¢ API à¸à¸à¸ Facebook à¸à¸à¸à¸à¸²à¸à¹à¸à¸´à¹à¸¡à¸à¸§à¸²à¸¡à¸ªà¸°à¸à¸§à¸à¹à¸«à¹à¸à¸±à¸à¸à¸¹à¹à¹à¸à¹à¸à¸²à¸à¹à¸§à¹à¸à¹à¸à¸à¹à¸à¸µà¹à¸ªà¸²à¸¡à¸²à¸£à¸à¹à¸à¹à¸²à¸ªà¸¹à¹à¸£à¸°à¸à¸à¹à¸à¸¢à¸à¸²à¸£à¸à¸¥à¸´à¸à¹à¸à¹à¸à¸¸à¹à¸¡à¹à¸à¸µà¸¢à¸§ ยัà¸à¸ªà¸°à¸à¸§à¸à¸à¸±à¸à¸à¸¹à¹à¸à¸±à¸à¸à¸²à¹à¸§à¹à¸à¹à¸à¸à¹à¸à¹à¸§à¸¢ à¹à¸à¸£à¸²à¸°à¸à¸±à¸§ API à¸à¸°à¹à¸«à¹à¸à¹à¸à¸¡à¸¹à¸¥à¸à¹à¸²à¸ ๠à¸à¸µà¹à¸à¹à¸à¸à¸à¹à¸²à¸à¸à¸£à¹à¸à¸¡à¹à¸à¹à¸à¸²à¸<!--more--></p>
<blockquote><p><a href="https://www.codebee.co.th/labs/examples/google_plus_login/" target="_blank" rel="noopener noreferrer">à¸à¸±à¸§à¸à¸¢à¹à¸²à¸à¸à¸²à¸£à¹à¸à¹à¸²à¸ªà¸¹à¹à¸£à¸°à¸à¸à¸à¸à¹à¸§à¹à¸à¹à¸à¸à¹à¸à¹à¸§à¸¢ Google+ javascript API</a></p></blockquote>
<p>à¸à¸µà¸à¸«à¸à¸¶à¹à¸à¹à¸à¹à¸à¸µà¸¢à¸¥à¸à¸µà¹à¹à¸«à¸¡à¸²à¸°à¸à¸±à¸à¸à¸²à¸£à¸à¸³à¸¡à¸²à¹à¸à¹à¸à¸²à¸à¹à¸à¸à¸²à¸£à¹à¸à¹à¸²à¸ªà¸¹à¹à¸£à¸°à¸à¸à¸«à¸£à¸·à¸à¸ªà¸¡à¸±à¸à¸£à¸ªà¸¡à¸²à¸à¸´à¸à¹à¸§à¹à¸à¹à¸à¸à¹à¸à¹à¸à¸·à¸ Google+ API à¸à¸¶à¹à¸à¸¡à¸µà¸«à¸¥à¸±à¸à¸à¸²à¸£à¹à¸à¹à¸à¸²à¸à¸à¸¥à¹à¸²à¸¢à¸à¸±à¸à¸à¸·à¸à¸à¸²à¸£à¸à¸ Permission สำหรัà¸à¸à¸²à¸£à¹à¸à¹à¸²à¸à¸¶à¸à¸à¹à¸à¸¡à¸¹à¸¥à¸à¹à¸²à¸ ๠à¸à¸²à¸à¸à¸±à¹à¸à¸à¹à¸£à¸±à¸à¸à¹à¸à¸¡à¸¹à¸¥à¸à¸·à¹à¸à¸à¸²à¸à¸à¹à¸²à¸ Callback à¸à¸±à¸à¸à¹à¸à¸±à¹à¸ ลà¸à¸à¸¡à¸²à¸à¸¹à¸à¸±à¸à¸à¸£à¸±à¸à¸§à¹à¸²à¹à¸£à¸²à¸à¸°à¸ªà¸²à¸¡à¸²à¸£à¸à¹à¸à¹à¸à¹à¸à¸¡à¸¹à¸¥à¸à¸²à¸ Google+ Account à¹à¸à¹à¸à¹à¸§à¸¢à¸§à¸´à¸à¸µà¹à¸«à¸</p>
<h4>สรà¹à¸²à¸à¹à¸à¸¥à¹ html หลัà¸à¹à¸¥à¸° Google Project</h4>
<ul>
<li>1. สรà¹à¸²à¸à¹à¸à¸¥à¹ index.html<br />
à¹à¸«à¹ include à¹à¸à¸¥à¹à¸«à¸¥à¸±à¸à¸à¸à¸ api à¹à¸§à¹à¹à¸à¸£à¸°à¸«à¸§à¹à¸²à¸ head tag à¹à¸¥à¸°à¸ªà¸£à¹à¸²à¸ meta tag สำหรัà¸à¹à¸ªà¹à¸£à¸«à¸±à¸ªà¹à¸à¸¥à¹à¸à¹à¸à¸à¹ à¸à¸±à¸à¸à¸µà¹</p>
<pre class="lang:default decode:true "><meta name="google-signin-client_id" content="รหัสà¹à¸à¸¥à¹à¸à¹à¸à¸à¹à¸à¸°à¹à¸à¹à¸«à¸¥à¸±à¸à¸à¸²à¸à¸ªà¸£à¹à¸²à¸ Google Project">
<;script src="https://apis.google.com/js/platform.js" async defer>;<;/script>;</pre>
</li>
<li>2. à¹à¸à¸à¸µà¹ <a href="https://console.developers.google.com" target="_blank" rel="noopener noreferrer">Google Developer Console</a><br />
สรà¹à¸²à¸à¹à¸à¸£à¹à¸à¸ Google à¹à¸¥à¸°à¹à¸à¸à¸µà¹à¹à¸¡à¸à¸¹ <strong>à¸à¹à¸à¸¡à¸¹à¸¥à¸£à¸±à¸à¸£à¸à¸ ->; สรà¹à¸²à¸à¸à¹à¸à¸¡à¸¹à¸¥à¸£à¸±à¸à¸£à¸à¸ ->; รหัสà¹à¸à¸¥à¹à¸à¹à¸à¸à¹ OAuth</strong></p>
<p><img width="400" src="https://www.codebee.co.th/labs/wp-content/uploads/2017/03/วิà¸à¸µà¸à¸³-google-plus-login-2.png" alt="วิà¸à¸µà¸à¸³-google-plus-login"></li>
<li>3. à¹à¸à¸à¹à¸à¸ à¸à¹à¸à¸à¸³à¸à¸±à¸ JavaScript à¹à¸£à¸´à¹à¸¡à¸à¹à¸à¸à¸µà¹à¹à¸à¹à¸£à¸±à¸à¸à¸à¸¸à¸à¸²à¸ à¹à¸«à¹à¸à¸´à¸¡à¸à¹à¸à¸·à¹à¸à¹à¸à¹à¸¡à¸à¹à¸§à¹à¸à¹à¸à¸à¹à¸à¸à¸à¹à¸£à¸²à¸à¸µà¹à¸à¸°à¹à¸à¹à¸à¸²à¸à¸à¸²à¸£à¹à¸à¹à¸²à¸£à¸°à¸à¸à¸à¹à¸§à¸¢ Google+
<p><img width="400" src="https://www.codebee.co.th/labs/wp-content/uploads/2017/03/วิà¸à¸µà¸à¸³-google-plus-login-3.png" alt="วิà¸à¸µà¸à¸³-google-plus-login"></li>
<li>4. à¹à¸«à¹à¸ªà¸±à¸à¹à¸à¸à¸¸à¹à¸à¸«à¸à¹à¸²à¸à¸µà¹à¸à¸°à¸à¸à¸à¸³à¸§à¹à¸² <strong>รหัสà¹à¸à¸¥à¹à¸à¹à¸à¸à¹</strong> à¹à¸«à¹à¸à¹à¸à¸à¸à¸µà¹à¸£à¸«à¸±à¸ªà¹à¸à¸§à¸²à¸à¹à¸à¸à¸à¹à¸à¸¡à¸¹à¸¥à¸à¸µà¹à¸§à¹à¸²à¸à¹à¸ meta tag à¸à¸µà¹à¹à¸£à¸²à¹à¸à¹à¸ªà¸£à¹à¸²à¸à¹à¸§à¹à¹à¸à¸à¹à¸à¹à¸£à¸
<p><img width="400" src="https://www.codebee.co.th/labs/wp-content/uploads/2017/03/วิà¸à¸µà¸à¸³-google-plus-login-1.png" alt="วิà¸à¸µà¸à¸³-google-plus-login"></li>
</ul>
<h4>สรà¹à¸²à¸à¸à¸¸à¹à¸¡ Login/Logout à¹à¸¥à¸°à¸£à¸±à¸à¸à¹à¸à¸¡à¸¹à¸¥ Google+ Account</h4>
<ul>
<li>1. à¹à¸à¸´à¸à¹à¸à¸¥à¹ index.html à¹à¸ªà¹à¸à¸³à¸ªà¸±à¹à¸à¹à¸à¸·à¹à¸à¹à¸à¸´à¹à¸¡à¸à¸¸à¹à¸¡à¹à¸à¹à¸²à¸ªà¸¹à¹à¸£à¸°à¸à¸à¹à¸à¸£à¸°à¸«à¸§à¹à¸²à¸ body tag à¸à¸±à¸à¸à¸µà¹
<pre class="lang:default decode:true "><;div class="g-signin2" data-onsuccess="onSignIn">;<;/div>;</pre>
</li>
<li>2. à¹à¸à¹ body tag สรà¹à¸²à¸à¸à¸±à¸à¸à¹à¸à¸±à¹à¸ javascript สำหรัà¸à¸£à¸±à¸à¸à¹à¸à¸¡à¸¹à¸¥ Google+ account à¹à¸¡à¸·à¹à¸à¸à¸¥à¸´à¸à¸à¸µà¹à¸à¸¸à¹à¸¡ Sigin à¸à¸±à¸à¸à¸µà¹
<pre class="lang:default decode:true "><;script>;
function onSignIn(googleUser) {
 var profile = googleUser.getBasicProfile();
 console.log('ID: ' + profile.getId());
 console.log('Name: ' + profile.getName());
 console.log('Image URL: ' + profile.getImageUrl());
 console.log('Email: ' + profile.getEmail()); 
}
<;/script>;</pre>
<p>สำหรัà¸à¸à¸²à¸£ Sign Out หรืà¸à¸à¸à¸à¸à¸²à¸à¸£à¸°à¸à¸à¸à¹à¸à¸°à¹à¸à¸µà¸¢à¸ javascript à¹à¸à¹à¸à¸£à¸°à¸¡à¸²à¸à¸à¸µà¹à¸à¸£à¸±à¸</p>
<pre class="lang:default decode:true "><;a href="#" onclick="signOut();">;Sign out<;/a>;
<;script>;
 function signOut() {
 var auth2 = gapi.auth2.getAuthInstance();
 auth2.signOut().then(function () {
 console.log('User signed out.');
 });
 }
<;/script>;</pre>
</li>
</ul>
<h4>à¸à¸à¸ªà¸à¸à¹à¸à¹à¸²à¸ªà¸¹à¹à¸£à¸°à¸à¸à¸à¹à¸§à¸¢ Google+ API</h4>
<p>à¸à¸±à¸à¹à¸«à¸¥à¸à¹à¸à¸¥à¹ index.html à¸à¸µà¹à¹à¸£à¸²à¹à¸à¹à¸ªà¸£à¹à¸²à¸à¹à¸§à¹à¸à¸¶à¹à¸à¹à¸à¸à¸à¹à¸®à¸ªà¸à¸´à¹à¸ à¹à¸à¹à¸¡à¸à¸à¸µà¹à¹à¸£à¸²à¸à¸³à¸«à¸à¸à¹à¸§à¹à¹à¸ Google Project หาà¸à¹à¸¡à¹à¸¡à¸µà¸à¸°à¹à¸£à¸à¸´à¸à¸à¸¥à¸²à¸ à¹à¸£à¸²à¸à¸°à¸à¸à¸à¸±à¸à¸à¸¸à¹à¸¡à¸ªà¸³à¸«à¸£à¸±à¸à¹à¸à¹à¸²à¸ªà¸¹à¹à¸£à¸°à¸à¸à¸à¸à¸ Google+ à¸à¸±à¸à¸£à¸¹à¸</p>
<p><img width="400" src="https://www.codebee.co.th/labs/wp-content/uploads/2017/03/วิà¸à¸µà¸à¸³-google-plus-login-4.png" alt="วิà¸à¸µà¸à¸³-google-plus-login"></p>
<p>à¹à¸«à¹à¸à¸à¸ªà¸à¸à¹à¸à¸¢à¸à¸²à¸£à¸à¸à¸à¸¸à¹à¸¡ <strong>ลà¸à¸à¸·à¹à¸à¹à¸à¹à¸²à¹à¸à¹</strong> à¸à¸°à¸à¸£à¸²à¸à¸à¸à¹à¸à¸à¸à¸±à¸à¹à¸ªà¸à¸à¸£à¸²à¸¢à¸à¸²à¸£ Permission à¹à¸«à¹à¸à¸à¸à¸¸à¹à¸¡ <strong>à¸à¸à¸¸à¸à¸²à¸à¸´</strong></p>
<p><img width="400" src="https://www.codebee.co.th/labs/wp-content/uploads/2017/03/วิà¸à¸µà¸à¸³-google-plus-login-5-1.png" alt="วิà¸à¸µà¸à¸³-google-plus-login"></p>
<p>หาà¸à¹à¸¡à¹à¸¡à¸µà¸à¸°à¹à¸£à¸à¸´à¸à¸à¸¥à¸²à¸à¹à¸¥à¸°à¹à¸£à¸²à¸ªà¸²à¸¡à¸²à¸£à¸à¹à¸à¹à¸²à¸ªà¸¹à¹à¸£à¸°à¸à¸à¹à¸à¹ à¸à¹à¸à¸à¸§à¸²à¸¡à¹à¸à¸à¸¸à¹à¸¡à¸à¸°à¹à¸à¸¥à¸µà¹à¸¢à¸à¹à¸à¹à¸ <strong>Signed in</strong> à¸à¸±à¸à¸£à¸¹à¸à¸à¹à¸²à¸à¸¥à¹à¸²à¸</p>
<p><img width="400" src="https://www.codebee.co.th/labs/wp-content/uploads/2017/03/วิà¸à¸µà¸à¸³-google-plus-login-6.png" alt="วิà¸à¸µà¸à¸³-google-plus-login"></p>
<p>à¹à¸à¸µà¸¢à¸à¹à¸à¹à¸²à¸à¸µà¹à¹à¸§à¹à¸à¹à¸à¸à¹à¸à¸à¸à¹à¸£à¸²à¸à¹à¸à¸°à¸ªà¸²à¸¡à¸²à¸£à¸à¹à¸à¹à¸à¹à¸à¸¡à¸¹à¸¥à¸à¹à¸²à¸à¸à¸²à¸ Google+ Account à¹à¸¥à¸°à¸à¸³à¸à¹à¸à¸¡à¸¹à¸¥à¹à¸à¹à¸à¹à¸à¸²à¸à¸ªà¸³à¸«à¸£à¸±à¸à¸à¸²à¸£à¹à¸à¹à¸²à¸ªà¸¹à¹à¸£à¸°à¸à¸à¸à¸à¹à¸§à¹à¸à¹à¸à¸à¹ สำหรัà¸à¸à¸²à¸£à¹à¸à¹à¸²à¸ªà¸¹à¹à¸£à¸°à¸à¸à¸à¹à¸§à¸¢à¹à¸à¸ªà¸à¸¸à¹à¸à¸ªà¸²à¸¡à¸²à¸£à¸à¸à¸¹à¹à¸à¹à¸à¸µà¹à¸à¸£à¸°à¸à¸¹à¹à¸à¸µà¹à¸à¸£à¸±à¸ <a href="https://www.codebee.co.th/labs/à¸à¸³à¸£à¸°à¸à¸-facebook-login-à¹à¸à¹à¸à¸à¹à¸à¸¡à¸¹à¸¥à¸à¸·à¹à¸/" target="_blank" rel="noopener noreferrer">https://www.codebee.co.th/labs/à¸à¸³à¸£à¸°à¸à¸-facebook-login-à¹à¸à¹à¸à¸à¹à¸à¸¡à¸¹à¸¥à¸à¸·à¹à¸/</a></p>

วิธีทำระบบ Login ด้วย Google Plus Javascript API

วิธีทำ-google-plus-login
