I'm "translating" a simple app I made with PHP to Python in order to use it in Google App Engine. In PHP I have the session check and the redirection with this code:
$fbuser = null;
$fb = null;
//Start Facebook
$fb = new Facebook(array(
'appId' => $appId,
'secret' => $secret,
'cookie' => true,));
$session = $fb->getSession();
if ($session) {
try {
$fbuser = $fb->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
}
}
if (!$fbuser) {
$loginUrl = $fb->getLoginUrl(array('canvas' => 1, 'fbconnect' => 0,
'req_perms' => 'publish_stream, offline_access, user_birthday, user_location, email',
'next' => $baseUrl,
'cancel_url' => $baseUrl ));
echo "<script type=\"text/javascript\">
top.location.href = \"$loginUrl\";
</script>";
exit;
}
I've seen the Python-SDK for Facebook but it's very poor and hasn't all the useful method as PHP-SDK! Can you help me translate this code to Python?