php - Facebook login integration to website on localhost -


my index.php file include this:

<div id="fb-root"></div> <script type="text/javascript"> window.fbasyncinit = function () {     fb.init({         appid: '<?php echo $appid; ?>',         cookie: true,         xfbml: true,         channelurl: '<?php echo $return_url; ?>channel.php',         oauth: true     }); }; (function () {     var e = document.createelement('script');     e.async = true;     e.src = document.location.protocol + '//connect.facebook.net/en_us/all.js';     document.getelementbyid('fb-root').appendchild(e); }());  function callafterlogin() {     fb.login(function (response) {         if (response.status === "connected") {             lodinganimate(); //animate login             fb.api('/me', function (data) {                  if (data.email == null) {                     //facbeook user email empty, can check this.                     alert("you must allow access email id!");                     resetanimate();                  } else {                     ajaxresponse();                 }              });         }     }, {         scope: '<?php echo $fbpermissions; ?>'     }); }  //functions function ajaxresponse() {     //load data server , place returned html matched element using jquery load().     $("#results").load("process_facebook.php"); }  //show loading image function lodinganimate() {     $("#loginbutton").hide(); //hide login button once user authorize application     $("#results").html('<img src="img/ajax-loader.gif" /> please wait connecting...'); }  //reset user button function resetanimate() {     $("#loginbutton").show(); //show login button      $("#results").html(''); //reset element html } </script>  process_facebook.php include         if(!empty($_server['http_x_requested_with'])&&strtolower($_server['http_x_requested_with']) == 'xmlhttprequest' )     {             //initialize facebook sdk $facebook = new facebook(array(     'appid' = > $appid,     'secret' = > $appsecret, ));  $fbuser = $facebook - > getuser();  if ($fbuser) {     try {         // proceed knowing have logged in user who's authenticated.         $me = $facebook - > api('/me'); //user         $uid = $facebook - > getuser();     } catch (facebookapiexception $e) {         //echo error_log($e);         $fbuser = null;     } }  // redirect user facebook login page if empty data or fresh login requires if (!$fbuser) {     $loginurl = $facebook - > getloginurl(array('redirect_uri' = > $return_url, false));     header('location: '.$loginurl); }  //user details $fullname = $me['first_name'].' '.$me['last_name']; $email = $me['email']; /* connect mysql using mysqli */ $mysqli = new mysqli($hostname, $db_username, $db_password, $db_name); if ($mysqli - > connect_error) {     die('error : ('.$mysqli - > connect_errno.') '.$mysqli - > connect_error); } //check user id in our database  $usercount = $mysqli - > query("select count(id) usercount usertable fbid=$uid") - > fetch_object() - > usercount; 

after check database , insert , update. still step step followed in blog:http://www.sanwebe.com/2012/05/ajax-facebook-connect-with-jquery-php

i facing problem. when login facebook keep on loading no further thing happen i.e. user data not able display. please provide me solution can display , store facebook user data.

in app settings in app dashboard, can write site url as-

http://localhost/harshtest/ 

then in app (i.e. /harshtest/index.php), can try facebook login , work.


enter image description here


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -