Shacobe Johnson
Shacobe Johnson

Reputation: 9

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 http://localhost/ but ends up being http://localhost/?state=010a4fc54ab86bcea7fb1d7ce9433291&code=AQD1X-gOIgfk95rdE-uH59OFkLOLH72VltBZRk_0ZK5qgtpykwwfaUrdNoSvQVJC7P0zVDmBDNhGbH1CiAzdEPaK08xcC8evrc7DUH1jvB7Al0Lyfz3kgeisW6pTORG_hsAUwqsNTekm6I6yKmoIMpUJkH9-7UUYqs5XvekpkcJ1WMkwGndAJzvG9iw5XnPuiUI#=

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.

Upvotes: 0

Views: 132

Answers (1)

Thabungba Meetei
Thabungba Meetei

Reputation: 11

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.

Upvotes: 1

Related Questions