Facebook PHP SDK login problem

Have you integrated a facebook login to your site, or are you planning to? There\'s a small bug involving the sign in process that can make your life miserable unless you know how to get around it. Here\'s one possible solution.

Why use facebook for user sign ins?

Implementing a facebook login for your site to get rid of having your own user verification may be a good idea, but it will probably not be a time saver.

Instead, you can quite possibly attract more users to actually sign in as they won\'t have to go through yet another sign up process with required fields, captchas and whatnot.

Once you\'ve read the documentation, downloaded their php sdk, set up your facebook app you will probably start implementing it and quickly have it ready for testing.

The facebook sign in bug

The problem you will most likely encounter is a bug that has been verified by facebook, and the description is:

  • You hit your facebook-login button
  • You\'re redirected to the facebook sign in page
  • You enter your credentials and accept the required permissions for your app
  • You\'re then redirected to your page where you try to read the user details

For some reason the last step won\'t work, but if you hit refresh on your page it will somehow magically work! In short, after signing in you need to refresh the page in your browser in order to get any user info out of the facebook PHP sdk.

 

One possible workaround

It\'s really simple, in the script you have set as redirect url for the facebook api, add the querystring \"?firsttime=true\". Then, before you output any data, check if the querystring \"firsttime\" is set. If it is, redirect to the same url but without the \"firsttime\" querystring.

There\'s currently no code samples for this article as I presume you are familiar with php redirects using header(\'Location: ... and that you have the sdk setup correctly.

Working example

 

 

 

 

Psst!

Besök min svenska sida om staden Hudiksvall och vad som finns där, en trevlig stad.

Hudiksvall

 

 Facebook Signin using the PHP SDK

Have you setup a facebook app and downloaded their sdk, and don\'t know where to go from there?

 Facebook PHP SDK login problem

Have you integrated a facebook login to your site, or are you planning to? There\'s a small bug involving the sign in process that can make your life miserable unless you know how to get around it. Here\'s one possible solution.

 Internet Explorer 9, JScript Error c00c023f

Ajax and Error c00c023f

After updating to Internet Explorer 9, a previously working ajax driven site of mine stopped working sporadically.

In this short article you will see how to reproduce, and how to solve the problem.

 Facebook Like button shows blank, solution

The \"EnkelAdress on Facebook\" button displayed just fine for a couple of days and then suddenly it showed up blank, no matter how many times trying to copy the code provided by Facebook. After quite some time digging deep in the information jungle we found the solution.

Page 1 / 2

 QuickTip: PayPal IPN - Complex Pass Through Data

Send complex data in the custom field that you use to match a payment with a customer, order or whatever you need.

 PayPal IPN - Take control over your incoming payments!

I'm sure you've heard all about the simplicity of using a payment processor service to sell your items online, but don't miss out on the ones who prefer using Paypal.

 QualityApp.net App Review Index

Having your app reviewed is a great way to boost your downloads! Read more on how QualityApp can help you find your mentions..

 DroidStop Android Apps

Despite popular belief, creating mobile apps and games is NOT the quick way to the millions!

 Would this interest you?

Page 2 / 11