Facebook Graph Api GET User email address mobile birthday
facebook graph api friends list example
In this post we will show you facebook Graph Api GET User email address mobile birthday , hear for facebook Graph Api GET User email address mobile birthdaywith example.Download and demo we will give you demo,Source Code and example for implement.
in this post you will show facebook graph api search Like as a User name,User birthday,User email Address,User education and User Mobile cell number list.
Requirements
What You Should Already Know
Before you study FaceBook dev Accounts,
need to HTML,
CSS,
JavaScript,
FaceBook Funda..
FaceBook Graph API
Browsers opetions
FaceBook APP ID (var fbAppId = ‘9568444152525458’;)
how to get access token facebook graph api?
Simple getAuthResponse() Method of used to get access token facebook graph api.
access_token = FB.getAuthResponse()['accessToken'];
Page Access Tokens using Facebook Graph Api
FB.api( '/me', 'GET', {"fields":"id,name,birthday,email,education"}, function(response) { console.log(response); access_token = FB.getAuthResponse()['accessToken']; Console.log(access_token); } );
facebook graph api Simple example Step By Step
Step 1 : Create a simple index.html
<html class="no-js"> <head> <title>Facebook graph api friends list example Step By step</title> <script src="index.js"></script> </head> <body> <div id="status"> </div> <div id="result"></div> <fb:login-button data-max-rows="1" data-size="large" data-button-type="continue_with" data-show-faces="true" data-auto-logout-link="true" data-use-continue-as="false" scope="public_profile,email" onlogin="checkLoginState();"> </fb:login-button> <pre id="resultdata"></pre> <pre id="resultdata1"></pre> <pre id="resultdata2"></pre> <pre id="resultdata3"></pre> <pre id="resultdata4"></pre> </body> </html>
Step 2 : Include Script index.js
<script> var fbAppId = '9568444152525458'; function statusChangeCallback(response) { if (response.status === 'connected') { testAPI(); personalAPI(); } else { document.getElementById('status').innerHTML = 'Please log ' + 'into this app.'; } } function checkLoginState() { FB.getLoginStatus(function(response) { statusChangeCallback(response); }); } window.fbAsyncInit = function() { FB.init({ appId : fbAppId, status : true, cookie : true, xfbml : true, version : 'v2.9', }); FB.getLoginStatus(function(response) { statusChangeCallback(response); }); }; // Load the Simple SDK Asynchronously (function(d, s, id){ var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) {return;} js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_US/sdk.js"; fjs.parentNode.insertBefore(js, fjs); }(document, 'script', 'facebook-jssdk')); function doit() { alert("Simple do it button clicked!"); } function testAPI() { FB.api('/me','GET',{"fields":"name,birthday"}, function(response) { document.getElementById('status').innerHTML = 'Thanks .. , If you are not ' + response.name + '! Please logout'; }); } function personalAPI() { FB.api( '/me', 'GET', {"fields":"name,birthday,email,education"}, function(response) { console.log(response); access_token = FB.getAuthResponse()['accessToken']; document.getElementById('resultdata').innerHTML = "<pre> <b>Access Token<b/> : "+access_token+"</pre>"; document.getElementById('resultdata1').innerHTML = "<pre> <b>User Name<b/> : "+response.name+"</pre>"; document.getElementById('resultdata2').innerHTML = "<pre> <b>User Email<b/> : "+response.email+"</pre>"; document.getElementById('resultdata3').innerHTML = "<pre> <b>User birthday<b/> : "+response.birthday+"</pre>"; document.getElementById('resultdata4').innerHTML = "<pre> <b>User education<b/> : "+response.education+"</pre>"; } ); } function hide (elements) { elements = elements.length ? elements : [elements]; for (var index = 0; index < elements.length; index++) { elements[index].style.display = 'none'; } } </script>