Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

FB PHP SDK Issue

  • 19-03-2014 02:20PM
    #1
    Registered Users, Registered Users 2 Posts: 1,991 ✭✭✭


    I'm trying to integrate the Facebook PHP SDK to allow users to login onto a website with their Facebook account. Below is the code I'm using, I'm logged into Facebook and the first time I go and click on the login link it pops up with the 'allow Facebook share profile information with this website' message which is grand, when I click OK it redirects back to the login page on the website still displaying the login URL.

    I did notice that there is a code parameter now in the address bar url with a long string.

    Can anyone suggest if I'm missing something or doing something wrong?!

    As always any help greatly appreciated, thanks.
    $vFacebook = new Facebook(array(
      'appId' => '....',
      'secret' => '....',
      'fileUpload' => false,
      'allowSignedRequest' => false,
    ));
    $vUID = $vFacebook->getUser();
    $vLoginURL = $vFacebook->getLoginUrl(); 
    
    if ($vUID)
    {
    	try {
    		$vFBUserProfile = $vFacebook->api('/me','GET');
    		var_dump($vFBUserProfile);
    		exit();	
    	}
    	catch (FacebookApiException $e)
    	{
    		echo 'Please <a href="' . $vLoginURL . '">login.2</a>';
    		error_log($e->getType());
    		error_log($e->getMessage());
    	}
    }
    else
    {
    	echo 'Please <a href="' . $vLoginURL . '">login.1</a>';
    }
    


Comments

Advertisement