时间:2010-07-26 03:07:26

标签: javascript facebook

3 个答案:

答案 0 :(得分:4)

答案 1 :(得分:1)

我在FB> UI调用Feed对话时遇到了类似的问题。我的页面是通过ajax加载的,而UI却没有。我刚刚禁用了FireBug,它开始出色地工作!猜猜FB在FireBug和FaceBook for Mozilla之间是不明确的。

答案 2 :(得分:0)

Thanks all this issue is due to 
<form id="fbform"></form>
<div id="fb-root"></div> is not included before script. you guys can try this code as i wrote.

div id="fb-root"></div>
    <script>
  //initializing API
  window.fbAsyncInit = function() {
    FB.init({appId: '298295206936650', status: true, cookie: true, xfbml: 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);
  }());
</script>
<script>
  //your fb login function
  function fblogin(action) {alert('dd');
      if(action == 'undefined'){
          var action = 'fb_login';
          }
      FB.login(function(response) {
       if (response.authResponse) {
         console.log('Welcome! Fetching your information.... ');
         FB.api('/me', function(response) { 
         var user = response;
         //alert(user.birthday)
         console.log(response)
         //alert(user.id+'---'+user.email);
         var picture_fb='https://graph.facebook.com/'+user.id+'/picture?width=100&height=100';
        // alert(picture_fb);
         if (user.current_location != null) {
            var city = user.current_location['city'];
            var country = user.current_location['country'];
         }else{
            var city = '';
            var country = '';
         }
         if(action == 'update_fb_pic'){

             var email_user= '<?=$this->session->userdata('user_id');?>';
             }else{

                 if(user.email !='' && user.email !=''){
                    var email_user= user.email;
                 }else{
                     var email_user= '';
                 }
            }

          $.ajax({
             type: 'POST',
             url: "<?php echo site_url()?>front/ajax_fb_login",
             data: "action="+action+"&fb_user_id="+user.id+"&username="+user.name+"&username="+user.name+"&first_name="+user.first_name+"&last_name="+user.last_name+"&gender="+user.gender+"&email="+email_user+"&avatar="+picture_fb+"&dob="+user.birthday,
             success: function(msg){
                //alert(msg);
                //window.parent.document.location.reload();
                window.location= "<?php echo site_url()?>profile"
                //$("#fbform").submit();
            }
          });
   });
       } else {
         console.log('User cancelled login or did not fully authorize.');
       }
     }, {   scope: 'email,user_birthday,status_update,read_stream,publish_stream'});



  }

</script>