登录过程、OAuth(脸书、推特)以及“;“正常方式”;登录


Login Process , OAuth (facebook,twitter) and also "Normal Way" login

我正在开发一个需要用户登录的web应用程序。

如何让我的用户(第一次)使用他们的Facebook或Twitter帐户登录,同时也让他们直接在我的应用程序中注册帐户。类似于混合登录系统。

如果用户直接注册了一个帐户,如何允许他们连接到他们的Facebook或Twitter帐户,然后让他们使用连接的Facebook或推特帐户登录。

任何教程、文章或关键词都可以让我做更多的研究?

对于Facebook:您可以使用PHP API和thy来获取用户。获取用户

    $facebook = new Facebook($config); // Get the Facebook class
    try{
        $facebookId = $facebook->getUser();
    } catch('Exception $e) {
        $facebookId = false;
    }
    if (!$facebookId) {
        /**
         * Redirect to authorization
         */
        $redirect = 'THIS_URL'; // FB will redirect here after auth.
        $scope = 'publish_stream, email';
        // Redirect user to URL provided by Facebook class
        return $this->redirect($facebook->getLoginUrl(array('redirect_uri' => $redirect, 'scope' => $scope)));
    }
    // Here you can find that user by $facebookId and authorize him or register him.