简体   繁体   中英

Facebook Authentication from PHP-SDK to Python

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\">\ntop.location.href = \"$loginUrl\";\n</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?

我认为SDK git存储库中的示例将为您提供提示。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM