I’ve got a problem with the facebook PHP-SDK in my oauth2 app. I use login via the JS-SDK but handle most of the app via PHP.
Here is my PHP code i use to handle this:
<?php
$uid = null;
include_once "lib/facebook.php";
if (stristr($_SERVER['HTTP_USER_AGENT'], 'MSIE'))
{
header('p3p: CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"');
}
$facebook = new Facebook(array(
'appId' => FB_APP_ID,
'secret' => FB_APP_SECRET,
'cookie' => true
));
$user = $facebook->getUser(); // this take for ever
if ($user) {
try {
$uid = trim($user);
$me = $facebook->api('/me');
} catch (FacebookApiException $e) {
echo $e;
try {
$uid = trim($user);
$me = $facebook->api('/me');
} catch (FacebookApiException $e) {
}
}
}
?>
I found out that $facebook->getUser(); is slowing down my app in the last 3 hours, some times it take up to 2 minutes until the script continues. But must of the time its 30+ seconds. Is there a way to cache this or a way to speed this up again?
Problem is resolved, the API is reacting fast enough again.