Skip to content

Instantly share code, notes, and snippets.

Created January 9, 2018 14:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/d618a6b6509f6bbe3f28b3d43c57b6aa to your computer and use it in GitHub Desktop.
Save anonymous/d618a6b6509f6bbe3f28b3d43c57b6aa to your computer and use it in GitHub Desktop.
Facebook Javascript Sdk Login Example
********************
Facebook Javascript Sdk Login Example ->->->->
********************
http://shurll.com/bzb72
(Copy & Paste link)
********************
Reload to refresh your session. My motto: "Language is not a barrier" posts by Ravishanker KusumaMost PopularjQuery AJAX Form Submit ExampleFacebook Javascript SDK TutorialjQuery AJAX POST ExamplePHP CURL POST & GET Examples Submit Form using PHP CURLHow to Send Cross Domain AJAX Request with jQueryGoogle URL Shortener API examplejQuery Submit Form ExampleDrag and Drop File Upload jQuery ExampleTOPICS AndroidAPIBug BountyCSSFacebookGmailGoogleInternetiOSJavaJavascriptjQueryMicrosoftNode.jsObjective-COpenSSLPdfPHPSwiftTwitterURL ShortenerWordpressXSSyoutubeAdvertisement Advertise with us Sharing is caring Please consider donating! Do you want to write articles in our Blog: Contact Us. Share Clone via HTTPS Clone with Git or checkout with SVN using the repository's web address. Feel free to click your browser's back button, or you can go to one of the following places: Developer.com home page Developer.com Java Section Developer.com Open Source Section Developer.com Microsoft & .NET Section Developer.com Database Section Developer.com PHP Section Developer.com Web Services Section Latest Developer.com News Enterprise Development Update Don't miss an article. Channel file is optional but it improves the Facebook Javascript SDK performance by addressing cross-domain issues in certain browsers.content of channel file is 3) Facebook SDK initialization. We were unable to find the page you asked for on Developer.com. } else { console.log('Authorization failed.'); } },{scope: 'email'}); }5) Get User Information by making API call to Graph API function getUserInfo() { FB.api('/me', function(response) { //response.name - User Full name //response.link - User Facebook URL //response.username - User name //response.id - id //response.email - User email }); }6) Add callback handler for authResponseChange events. It looks like nothing was found at this location. FB.Event.unsubscribe Unsubscribe the specified eventsFollow the below steps to make your first JavaScript App:1) You need a Facebook App ID to use Facebook Javascript SDK,Check Creating Facebook App section in Add a Channel file in your website. Embed Share Copy sharable URL for this gist. 2018 GitHub, Inc. .. Create a gist now Instantly share code, notes, and snippets. Maybe try one of the links below or a search? Search for: . Reload to refresh your session. hayaGeekCodingHowSecurityTutorials Sections CodingHowSecurityTutorials SubmitSubmit Tutorial Follow UsFacebookTwitterGoogle+PinterestRSS Feed HelpRequest TutorialContactWrite for UsAdvertise CodingHowSecurityTutorials CodingHowSecurityTutorialsFacebook Javascript SDK Tutorial by Ravishanker Kusuma in Coding, Tutorials Jul 10th 2013 0 Comments In this tutorial,I have covered how to use Facebook Javascript SDK. Already have an account? Sign in to comment . Add the below code to your HTML file. Java Microsoft & .NET Mobile Android Open Source Cloud Database Architecture Other Project Management PHP Perl Ruby Services Other Languages White papers Research Center NEW: Slideshows Sponsored January 9, 2018 Hot Topics: prev Android Java PHP Microsoft & .NET Cloud Open Source Database next We're Sorry. Recent Posts Building a Lazy Loader for React Facebook PHP SDK 5.0 Tutorial Raspberry Pi for N00bs Compiling and Installing Node.js LinksBernd PfeifferMatthias ZeisPhilipp Pfaller. You signed in with another tab or window. .. You signed out in another tab or window. Sign up for free to join this conversation on GitHub. All Rights Reserved.Powered by: WordpressFonts by: FontDeck . Logged Out } });6) Write a Method for Logoutfunction Logout() { FB.logout(function(){document.location.reload();}); }Working Facebook Javascript SDK Example window.fbAsyncInit = function() { FB.init({ appId : '113455642165175', // Set YOUR APP ID channelUrl : ' // Channel File status : true, // check login status cookie : true, // enable cookies to allow the server to access the session xfbml : true // parse XFBML }); FB.Event.subscribe('auth.authResponseChange', function(response) { if (response.status === 'connected') { document.getElementById("message").innerHTML += " Connected to Facebook"; //SUCCESS } else if (response.status === 'notauthorized') { document.getElementById("message").innerHTML += " Failed to Connect"; //FAILED } else { document.getElementById("message").innerHTML += " Logged Out"; //UNKNOWN ERROR } }); }; function Login() { FB.login(function(response) { if (response.authResponse) { getUserInfo(); } else { console.log('User cancelled login or did not fully authorize.'); } },{scope: 'email,userphotos,uservideos'}); } function getUserInfo() { FB.api('/me', function(response) { var str=" Name : "+response.name+" "; str +=" Link: "+response.link+" "; str +=" Username: "+response.username+" "; str +=" id: "+response.id+" "; str +=" Email: "+response.email+" "; str +=" "; str +=" "; document.getElementById("status").innerHTML=str; }); } function getPhoto() { FB.api('/me/picture?type=normal', function(response) { var str=" Pic : "; document.getElementById("status").innerHTML+=str; }); } function Logout() { FB.logout(function(){document.location.reload();}); } // Load the SDK asynchronously (function(d){ var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/enUS/all.js"; ref.parentNode.insertBefore(js, ref); }(document)); Facebook OAuth Javascript Demo Click on Below Image to start the demo: Logs: Reference: I am a Developer. Most Popular Developer Stories Today This Week All-Time 1 Using JDBC with MySQL, Getting Started 2 Creating Use Case Diagrams 3 An Introduction to Java Annotations 4 Hibernate Basics 5 Using ASP.NET To Send Email 1 Using JDBC with MySQL, Getting Started 2 10 Experimental PHP Projects Pushing the Envelope 3 Hibernate Basics 4 An Introduction to Java Annotations 5 Oracle Programming with PL/SQL Collections 1 Using JDBC with MySQL, Getting Started 2 Hibernate Basics 3 Oracle Programming with PL/SQL Collections 4 An Introduction to Java Annotations 5 Creating Use Case Diagrams Most Commented On This Week This Month All-Time 1 10 Experimental PHP Projects Pushing theEnvelope2 Day 1: Learning the Basics of PL/SQL3 C# Tip: Placing Your C# Application in theSystem Tray4 Logical Versus Physical Database Modeling5 Is Ubuntu Contributing as Much as It Should toFree Software Projects? 1 Day 1: Learning the Basics of PL/SQL2 The 5 Developer Certifications You'll Wish YouHad in 20153 10 Experimental PHP Projects Pushing theEnvelope4 An Introduction to Struts5 Inside Facebook's Open Source Infrastructure 1 Creating Use Case Diagrams2 Day 1: Learning the Basics of PL/SQL3 C# Tip: Placing Your C# Application in theSystem Tray4 Using ASP.NET To Send Email5 Using JDBC with MySQL, Getting Started Sitemap Contact Us Thanks for your registration, follow us on our social networks to keep up-to-date . Using this SDK, you can get the full functionality of Facebook OAuth at client-side. Oops! That page can’t be found. Skip to content All gists GitHub Sign up for a GitHub account Sign in . This is optional.FB.Event.subscribe('auth.authResponseChange', function(response) { if (response.status === 'connected') { //SUCCESS } else if (response.status === 'notauthorized') { //FAILED } else { //UNKNOWN ERROR. i.e., Getting User Information/Posting to Wall/Reading Messages can be done with pure JavaScript, It doesnt require any server-side programming.List of Core APIs in Facebook Javascript SDKFB.init Initialize the SDK with your APP ID FB.api For making API calls to Graph API FB.ui For triggering Facebook Dialogs like OAuth Dialog, Feed Dialog, Friends Dialog, Request Dialog, Send Dialog, Pay Dialog, Add Page Tab DialogFB.login Login to Facebook using OAuth Dialog FB.logout Logout the user from FacebookFB.getLoginStatus For checking whether user is logged in and authenticated App FB.getAuthResponse - Similar to FB.getLoginStatus, but it is synchronous and returns authResponse Object.FB.Event.subscribe Subscribe for events (auth.login, auth.authResponseChange, auth.statusChange) and get callbacks to your function when event is fired. You can't perform that action at this time. HTTPS Learn more about clone URLs Download ZIP Code Revisions 2 Stars 13 Forks 4 Facebook Javascript SDK: Basic Login and Logout example Raw javascript window.fbAsyncInit = function() { FB.init({ appId: 'xxxxxxxxxxxxx', status: true, cookie: true, xfbml: true }); }; // Load the SDK asynchronously (function(d){ var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; if (d.getElementById(id)) {return;} js = d.createElement('script'); js.id = id; js.async = true; js.src = "//connect.facebook.net/enUS/all.js"; ref.parentNode.insertBefore(js, ref); }(document)); function login() { FB.login(function(response) { // handle the response console.log("Response goes here!"); }, {scope: 'readstream,publishstream,publishactions,readfriendlists'}); } function logout() { FB.logout(function(response) { // user is now logged out }); } var status = FB.getLoginStatus(); console.log(status); Login Facebook Logout from Facebook montesleonil commented Dec 18, 2015 i learned something new ZhaoheXu1993 commented Jun 26, 2017 When I use chrome, the process of logout costs a lot of time. Terms Privacy Security Status Help Contact GitHub API Training Shop Blog About 5a02188284
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment