Hi all,
I have tried following the FB mobile web "getting started guide" at:
https://developers.facebook.com/docs/guides/mobile/web/ for a web app that I open full-screen on my iphone (or when I use an embedded UIWebView in my native app - same result).
but when I try to login using the fb login page that opens up, I get a blank white screen after I click the "login" button. The user IS logged in though.. I know this because if I close and reopen my web app, I check the login status and try to get some user info, and it works fine...
When I try the same web app in my desktop's chrome or my iphone's safari, the login process is ok... it break only from within the full screen web app or embedded UIWebView. Note also that I tried removing the "apple-mobile-web-app-capable" - same result from within a UIWebView.
any ideas?? I'm merely following the sample code from FB :-( Did anyone manage to get this to work?
The sample code is as described in the fb tutorial. Basically, the auth.login event does not seem to get called in the mentioned situations.
Code:
<?php
require 'facebook-php-sdk/src/facebook.php';
$facebook = new Facebook(array(
'appId' => 'my_app_id',
'secret' => 'my_app_secret',
));
// See if there is a user from a cookie
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
echo '<pre>'.htmlspecialchars(print_r($e, true)).'</pre>';
$user = null;
}
// Login or logout url will be needed depending on current user state.
if ($user) {
$logoutUrl = $facebook->getLogoutUrl();
} else {
$loginUrl = $facebook->getLoginUrl();
}
}
?>
<!DOCTYPE html>
<html xmlns:fb="http://www.facebook.com/2008/fbml">
<head>
<title>MyApp</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes" />
</head>
<body>
<?php if ($user_profile) { ?>
<a href="#" onclick="FB.logout();">Logout</a>
Your user profile is
<pre>
<?php print htmlspecialchars(print_r($user_profile, true)) ?>
</pre>
<?php } else { ?>
<fb:login-button></fb:login-button>
<?php } ?>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {
FB.init({
appId: '<?php echo $facebook->getAppID() ?>',
cookie: true,
xfbml: true,
oauth: true
});
FB.Event.subscribe('auth.login', function(response) {
window.location.reload();
});
FB.Event.subscribe('auth.logout', function(response) {
window.location.reload();
});
};
(function() {
var e = document.createElement('script'); e.async = true;
e.src = document.location.protocol +
'//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
}());
</script>
</body>
</html>
thanks.