简体   繁体   中英

facebook app not working after loging

i am tray to make an facebook app, i follow the tutorial in this site FACEBOOK SDK 4.0.0 FOR PHP: A WORKING SAMPLE TO MANAGE SESSIONS

first if the user in not logged in then the app will generate a login link, after logging the app will show the user basic information.

My problem is after logging in, the app show blank page, and the url changed to like this

app_url.com/?code=AQCJaz_qzcEzVkJqM-vqfSuX

my app hosted in heroku, http://karimfacebookapp.herokuapp.com

For Create App please see :

在此处输入图片说明

在此处输入图片说明

Please put below code in Your index file for app

  <html>
  <script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
  <script type="text/javascript">
  /*Start Facebook Javascript SDK Call*/
      window.fbAsyncInit = function() {  
          // for js api initialization
          FB.init({
          appId  : 'Your APP ID', // APP ID
          status : true, // check login status
          cookie : true, // enable cookies to allow the server to access the session
          xfbml  : true, // parse XFBML
          oauth  : true // enable OAuth 2.0
          });
      };
      (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/all.js";//#xfbml=1";
        js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=Your APP ID";
        //js.src = "js/connect.facebook.js";
        fjs.parentNode.insertBefore(js, fjs);
      }(document, 'script', 'facebook-jssdk'));
  /*End Facebook Javascript SDK Call*/

      /** Start script for get login user info */
      $( window ).load(function() {
          FB.login(function() {
                FB.api('/me', function(response) {
                  $('.data').html("Name is "+response.first_name);
                });
              });
          });
  /** End script for get login user info */
  </script>              
  <body>
  <?php echo "Chirag Shah FB Demo";?>
   <div id="fb-root"></div><br><br><br><br><br>
   <div class="data"></div>
  </body>
  </html>

Now run this app, after login it can not redirect on blank page.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM