2011-02-02 3 views
2

내 사이트의 로그인을 구현합니다. 로그인 방법을 다소 stackoverflow에서 구현하는 방법을 원합니다. 그러나 Gmail 옵션은 하나만 사용하십시오. 1) 사용자는 그는 내가이 ..Any 도움말 PLZ 매우 새로운 오전 자신의 Gmail 사용자 이름과 비밀번호 3) 그는 사이트Gmail을 사용하여 사이트에 로그인

다시 redirecred해야를 입력해야합니다 2)의 Gmail로 로그인 유형을 선택해야합니다

+0

이 링크에 미치는라는 오픈 ID보기 http://technofriends.in/2008/11/10/what-is-openid-and-how-to-use-gmail-account-as-openid/ –

답변

5

를 참조 읽어보십시오. 해당 사례를 염두에두고 an example을 사용할 수 있습니다.

  • 내 서버에 www 폴더를 매핑 한 :

    <?php 
    # Logging in with Google accounts requires setting special identity, so this example shows how to do it. 
    require 'openid.php'; 
    try { 
        $openid = new LightOpenID; 
        if(!$openid->mode) { 
         if(isset($_GET['login'])) { 
          $openid->identity = 'https://www.google.com/accounts/o8/id'; 
          header('Location: ' . $openid->authUrl()); 
         } 
    ?> 
    <form action="?login" method="post"> 
        <button>Login with Google</button> 
    </form> 
    <?php 
        } elseif($openid->mode == 'cancel') { 
         echo 'User has canceled authentication!'; 
        } else { 
         echo 'User ' . ($openid->validate() ? $openid->identity . ' has ' : 'has not ') . 'logged in.'; 
        } 
    } catch(ErrorException $e) { 
        echo $e->getMessage(); 
    } 
    

    이 당신을 얻으려면과 실행은 정말 간단하다 (I *이 시스템과 같은 괜찬아가 가정).

  • localhost에서 실행중인 서버가 있다고 가정합니다.
  • Google 크롬이 설치되어 있다고 가정합니다.

[email protected]:~/www$ wget http://gitorious.org/lightopenid/lightopenid/archive-tarball/master 
--2011-02-02 13:21:30-- http://gitorious.org/lightopenid/lightopenid/archive-tarball/master 
Resolving gitorious.org... 87.238.52.168 
Connecting to gitorious.org|87.238.52.168|:80... connected. 
HTTP request sent, awaiting response... 200 OK 
Length: 17104 (17K) [application/x-gzip] 
Saving to: `master' 

100%[======================================>] 17,104  --.-K/s in 0.04s 

2011-02-02 13:21:30 (386 KB/s) - `master' saved [17104/17104] 

[email protected]:~/www$ tar xfz master 
[email protected]:~/www$ google-chrome http://localhost/lightopenid-lightopenid/example-google.php 
Created new window in existing browser session. 
+0

고마워요 .. 전체 간단한 예제를 줄 수는 ... –

+0

이것은 아주 간단한 예입니다;). tarball을 다운로드하면이 예제를 실행할 수 있습니다.> http://gitorious.org/lightopenid/lightopenid/archive-tarball/master – Alfred

+0

예. 알아요.하지만 로그 아웃하는 방법은 ..... –

0
+0

잘 문서화 된 소스에 대한 외부 참조를 포함하는 것은 Stack Overflow에서 평가할 수 있지만 외부 소스의 가장 중요한/관련 발췌 부분을 사용자의 대답에 포함시키고 질문에 대답하는 방법에 대한 컨텍스트를 제공하는 것이 중요합니다. – mbinette

관련 문제