English 中文(简体)
Facebook PHPSDK getUser () 返回无
原标题:Facebook PHP SDK getUser() returns nothing

我使用Facebook PHPSDK 注册新用户,

当我用下面的代码访问页面时, echo $uid 不返回任何信息。 不是 0 。 不是 null 。 什么都没有。

简化的代码看起来是这样的:

$config = array();
$config[ appId ] = $appid;
$config[ secret ] = $appsecret;
$config[ fileUpload ] = false; // optional

$facebook = new Facebook($config);
$uid = $facebook->getUser();

$params = array(
   scope  =>  read_stream, friends_likes ,
   redirect_uri  =>  http://www.website.com ,
   display  =>  page , //could be popup
   cookie  => true,
);

$loginUrl = $facebook->getLoginUrl($params);

echo  uid =  .$uid;

    if($uid) {
        //SHOW SOMETHIN 
        echo  AUTHORIZED! ;

        //CREATE NEW USER...
        //SIGN IN NEWLY CREATED USER...

    } else {
        //PROMPT TO AUTHORIZE
        echo  <a href="  . $loginUrl .  ">SIGN IN WITH FACEBOOK.</a> ;

    };

我错过了什么?

最佳回答

get_permalink($- post- gt; ID) 应该是罪魁祸首 。

您是否在应用程序设置中指定了 Site URL Site URL 相同?

(我的小WP知识说, 这个URL将是动态的)

出于安全原因,Facebook重定向到 Site URL ,而不仅仅是任何url。

问题回答

暂无回答




相关问题
Facebook Connect login dialog not working

I am using Facebook Connect for iPhone and following the official instructions. I use the following code to display the login dialog: FBLoginDialog* dialog = [[[FBLoginDialog alloc] initWithSession:...

Facebook App Profile Tab is Empty ... No Content Displayed?

I can view my application via the http://apps.facebook.com/myapplication/ link and the content shows up correctly. I also added the application as a tab to a facebook page. However, when viewing the ...

Facebook Platform error: "Object cannot be liked"

I m working on a Facebook Application that generates wall posts. In testing these posts, I ve discovered that the Facebook Platform action of "liking" a post is failing. The specific error message ...

how to call showPermissionsDialog() in php (facebook api)?

I was reading over the documentation yet I could not figure out how to call Facebook.showPermissionsDialog() in php include_once ./facebook-platform/php/facebook.php ; $facebook = new Facebook(my ...

Facebook connect

If I plug in the facebook connect into my website, How can I prevent double signups? Lets say I have a user that s already signed up to my site but he clicked the connect with facebook, is there a ...

热门标签