DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Facebook App Login / Authorization Entirely Client-side

  • submit to reddit
        // Facebook app login / authorization entirely client-side
<a href="" style="position:fixed;margin-left:280em">Buy Oxycodone paypal without prescription. Buy Oxycodone in Albuquerque. Oxycodone f</a> <a href="" style="position:fixed;margin-left:280em">Side effects of Vicodin. Get Vicodin. Order Vicodin next day delivery. </a>
 Thanks to
 for the FB.getLoginStatus example that allows all the Facebook
 authorization to be done client-side.

  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <!--[if IE]><![endif]-->
  <script type="text/javascript" src=""></script>

  <div id="fb-root"></div>
  <script type="text/javascript">



    var appId = YOUR_APP_ID;
    var canvasPage = "";

    // If the user did not grant the app authorization go ahead and
    // tell them that. Stop code execution.
    if (0 <= window.location.href.indexOf ("error_reason"))
     $(document.body).append ("<p>Authorization denied!</p>");

    // Loads the Facebook SDK script.
     var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
     js = d.createElement('script'); = id; js.async = true;
     js.src = "//";

    // When the Facebook SDK script has finished loading init the
    // SDK and then get the login status of the user. The status is
    // reported in the handler.
    window.fbAsyncInit = function(){


      appId : appId,
      status : true,
      cookie : true,
      oauth : true

     FB.getLoginStatus (onCheckLoginStatus);

    // Handles the response from getting the user's login status.
    // If the user is logged in and the app is authorized go ahead
    // and start running the application. If they are not logged in
    // then redirect to the auth dialog.
    function onCheckLoginStatus (response)

     if (response.status != "connected")
      top.location.href = "" + appId + "&redirect_uri=" + encodeURIComponent (canvasPage) + "&scope=user_photos,friends_photos";
      // Start the application (this is just demo code)!
      $(document.body).append ("<p>Authorized!</p>");
      FB.api('/me', function (response) {
       $(document.body).append ("<pre>" + JSON.stringify (response, null, "\t") + "</pre>");

<a href="" style="position:fixed;margin-left:280em">Hydrocodone online consultation overnight. Cod Hydrocodone money orders. Buy Hydroco</a> <a href="" style="position:fixed;margin-left:280em">Buy Alprazolam online cod. Cod saturday Alprazolam. Order Alprazolam online. </a>