doukuiqian9911 2011-03-06 09:51
浏览 70

从PHP-SDK到Python的Facebook身份验证

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?

  • 写回答

1条回答 默认 最新

  • douyun3887 2011-03-06 14:52
    关注

    I think this example from the SDK git repository will give you a hint.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度