我正在使用帶有Codeigniter的PHP SDK實現Facebook登錄。我得到Facebook登錄彈出窗口,點擊登錄,但我無法檢索用戶的ID - 它總是返回0.Facebook getUser()返回0
我已經將facebook.php和base_facebook.php文件放在我的庫文件中,並將其作爲Codeigniter中的庫遵循教程here。
誰能告訴我他們在想什麼嗎?我使用下面的代碼 -
視圖 - Facebook登錄按鈕
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId : '<?php echo $this->config->item('facebook_app_id'); ?>',
status : true,
cookie : true,
xfbml : true,
oauth : true,
});
FB.Event.subscribe('auth.login', function() {
window.location='<?php echo base_url(); ?>auth_other/fb_signin/';
});
};
(function(d){
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
js = d.createElement('script'); js.id = id; js.async = true;
js.src = "//connect.facebook.net/en_US/all.js";
d.getElementsByTagName('head')[0].appendChild(js);
}(document));
</script>
<div class="fb-login-button">Login with Facebook</div>
控制器 - auth_other/fb_signin
function fb_signin()
{
$fb_user = null;
$fb_config = array(
'appId' => $this->config->item('facebook_app_id'),
'secret' => $this->config->item('facebook_app_secret')
);
$this->load->library('facebook',$fb_config);
$fb_user = $this->facebook->getUser();
echo $fb_user;
不正確,如果顯示的畫布網址爲上述工作,即使在本地主機的「http://本地主機/我的偉大,應用程序/」,並在應用程序域「localhost」的 – dendini 2014-02-14 09:41:30