简体   繁体   中英

PHP Facebook-SDK

I've been racking my brain all day trying to get this Facebook-SDK to work.. It all connects but when it returns to my URL nothing happens at all. This is all done on my localhost just for a test..

Here's my dummy code..

$Session = $this->Manhattan->GetFacebook()->getUser();

if ($Session)
{
    die('Authenicated');
}
else
{
    header('Location: ' . $this->Manhattan->GetFacebook()->getLoginUrl());
}

The return url is supposed to be but ends up being 但最终被

This is always the result..

 Facebook::getUser() = 0;

Could anyone point out why? I rather use the PHP SDK than the Javascript SDK so please don't point me in that direction.

Thanks.

Yes, it always returns 0 and creates a loop of redirections from the facebook login to my localhost"

This is happening because

$Session=$this->Manhattan->GetFacebook()->getUser();

always holds 0. So it goes to the else part of your code and executes

header('Location: ' . $this->Manhattan->GetFacebook()->getLoginUrl());

try localhost.local instead of localhost . Don't forget to change in facebook app settings.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM