$ facebook-> getSession()调用在呼叫下面打破页面 [英] $facebook->getSession() call breaks page below the call

查看:91
本文介绍了$ facebook-> getSession()调用在呼叫下面打破页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 < div id =fb-root> < / div>< script src =http://connect.facebook.net/en_US/all.js#appId=my_app_id&amp;xfbml=1> 
< / script>< fb:login-button show-faces =falseperms =user_hometown,user_about_me,email,user_addressautologoutlink =truewidth =200max-rows =1 >
< / fb:login-button>

<?php

if($ facebook-> getSession())
{
//这里还没有
}

?>

但是调用$ facebook-> getSession()似乎打破了页面。此通话下方的任何内容都不会显示。任何想法为什么?或者我做错了什么?



这是我试图测试的页面:
http://www.comehike.com/test_fb_connect.php

解决方案

如果这是您的整个PHP文件,那么您的引用 $ facebook 尚未声明。您将要包含PHP SDK的位置,然后使用您的appID和密码初始化 $ facebook 。这个格式已经改变了v3.0.0的PHP SDK, here



V 2.2.X

  require'../src /facebook.php'; 

$ facebook = new Facebook(array(
'appId'=>'12345678910',
'secret'=>'********* ********************',
));

$ session = $ facebook-> getSession();
if($ session){
//继续知道你有一个有效的用户会话
} else {
//继续知道你需要用户登录和/或身份验证
}

V 3.0.0

  require'../src/facebook.php'; 

$ facebook = new Facebook(array(
'appId'=>'12345678910',
'secret'=>'********* ********************',
));

$ user = $ facebook-> getUser();
if($ user){
//继续知道你有一个登录的用户谁被认证
} else {
//继续知道你需要用户登录和/或身份验证
}


I have this code to log people in with Facebook:

<div id="fb-root"></div><script src="http://connect.facebook.net/en_US/all.js#appId=my_app_id&amp;xfbml=1">
</script><fb:login-button show-faces="false" perms="user_hometown,user_about_me,email,user_address" autologoutlink="true" width="200" max-rows="1">
</fb:login-button>

<?php

if($facebook->getSession())
{
 // Nothing here yet
}

?>

But the call to $facebook->getSession() seems to break the page. Nothing below this call gets displayed. Any idea why? Or what I am doing wrong?

Here is the page where I am trying to test this: http://www.comehike.com/test_fb_connect.php

解决方案

If that's your entire PHP file then your referencing $facebook which hasn't been declared yet. You'll want to include the location of the PHP SDK then initialize $facebook with your appID and secret. This format has changed with v3.0.0 of the PHP SDK found here.

V 2.2.X

require '../src/facebook.php';

$facebook = new Facebook(array(
      'appId'  => '12345678910',
      'secret' => '*****************************',
    ));

$session = $facebook->getSession();
if ($session) {
  // proceed knowing you have a valid user session
} else {
  // proceed knowing you require user login and/or authentication
}

V 3.0.0

require '../src/facebook.php';

$facebook = new Facebook(array(
  'appId'  => '12345678910',
  'secret' => '*****************************',
));

$user = $facebook->getUser();
if ($user) {
  // proceed knowing you have a logged in user who's authenticated
} else {
  // proceed knowing you require user login and/or authentication
}

这篇关于$ facebook-&gt; getSession()调用在呼叫下面打破页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆