2011-01-19 3 views
1

내 웹 사이트를 방문한 페이스 북 사용자의 이메일 주소를 페이스 북에 가져 오는 응용 프로그램을 개발하려고합니다. 예를 들어 yahoo 연락처 수입업자 및 다른 연락처 수입업자와 같은 것입니다.로그인 한 페이스 북 사용자로부터 이메일 주소를 가져 오시겠습니까?

  1. 사용자 'X'이 (가) Facebook에 로그인했습니다.
  2. 앱에 친구의 UID 집합 (사용자 'X'의 가능한 친구)이 있습니다.
  3. 이 UID의 전자 메일 주소를 가져 오려고하지만 UID, 생일, 이름, first_name, last_name 만 쿼리 결과에 나타나고 전자 메일 주소는 NULL로 표시됩니다.

    (perms:'publish_stream,read_stream,offline_access,manage_pages,friends_activities,friends_about_me,user_hometown,user_birthday,user_about_me,user_hometown,user_photos,email,manage_friendlists,read_friendlists') 
    

참고 : 그러나, 나는처럼, 친구와 관련된 모든 확장 된 권한을 추가 나는 개발자를위한 페이스 북의 API를 탐색하고 해결책을 찾을 수 없습니다.

내 코드 :

<body> 

<h1>Login to FaceBook using My Web Application</h1> 

<div> 
    <button id="login">Log In</button> 
    <button id="logout">Log Out</button> 

    <button id="disconnect">Disconnect</button> 

</div> 

<div id="user-info" style="display: none;"></div> 

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> 

<div id="fb-root"></div> 

<script src="http://connect.facebook.net/en_US/all.js"></script> 

<script> 
    // initialize the library with the API key 
    FB.init({ apiKey: 'c2e2e62acc6a292c20c63404bcfecb23' }); 

    // fetch the status on load 
    FB.getLoginStatus(handleSessionResponse); 

    $('#login').bind('click', function() { 
    FB.login(handleSessionResponse,{perms:'publish_stream,read_stream,offline_access,manage_pages,friends_activities,friends_about_me,user_hometown,user_birthday,user_about_me,user_hometown,user_photos,email,manage_friendlists,read_friendlists'}); 
    }); 

    $('#logout').bind('click', function() { 
    FB.logout(handleSessionResponse); 
    }); 

    $('#disconnect').bind('click', function() { 
    FB.api({ method: 'Auth.revokeAuthorization' }, function(response) { 
     clearDisplay(); 
    }); 
    }); 

    // no user, clear display 
    function clearDisplay() { 
    $('#user-info').hide('fast'); 
    } 

    // handle a session response from any of the auth related calls 
    function handleSessionResponse(response) { 
    // if we dont have a session, just hide the user info 
    if (!response.session) { 
     clearDisplay(); 
     return; 
    } 

    FB.api(
     { 
     method: 'fql.query', 
     query: 'SELECT pic,hometown_location,name,username, uid, email, sex, birthday FROM user WHERE uid=' + FB.getSession().uid 

     }, 
     function(response) { 
     var user = response[0]; 

     $('#user-info').html("<img src="+user.pic+"/>"+'<br/>ID: '+user.uid +'<br/>User Name: '+ user.name +'<br/>Email: '+ user.email +'<br/>Birth Day: '+ user.birthday +'<br/>Gender: ' + user.sex+'<br/>Home Town: ' +user.hometown_location['state']).show('fast'); 

     } 
    ); 

    // if we have a session, query for the user's profile picture and name 
    FB.api(
    { 
    method: 'friends.get' 
    }, 
    function(response) 
    { 

    $(response).each(function() { 
    var userid = this; 
    FB.api(
    { 
     method: 'fql.query', 
     query: 'SELECT uid,name,email,birthday FROM user WHERE uid=' + userid 
    },function(response) 
    { 
    var user = response[0] 
    $('#user-info').append('<br/>ID: '+user.uid+ ', Name: '+user.name+' ,Email: '+user.email); 

    }); 
    }); 
    } 
    ); 

    } 

</script> 

</body> 

답변

1

당신은 FQL을 통해 사용자의 친구의 이메일 해시를 얻을 수있다 (표 "사용자"의 필드 "email_hashes").

페이스 북 사용자에게 사용자를 바인딩하는 또 다른 방법 - "검색"방법 사용 (이메일로 페이스 북 사용자를 검색 할 수 있음). 나는 같은 문제가있을 때 그것을 사용했다. 예를 들어

,이 API 호출 :

/[email protected]&type=user 

반환 :

{ 
    "data": [ 
     { 
     "name": "Pavel Surmenok", 
     "id": "100001653100014" 
     } 
    ] 
} 

당신은 당신의 이메일을 반복하고 페이스 북에 등록 여부를 검색 할 수 있습니다.

+0

미안 내가 로그인 한 후 내 friendsList에서 이메일을 추출해야, 난 페이스 북이 이메일을 추출 할 수 없습니다 레지스터 –

+0

확인하기 위해 이메일 연락처가없는 돈. 이메일 해시 만받을 수 있습니다. –

+0

아 ... 나는 "페이스 북 사용자로 로그인 한 이메일을 내 웹 사이트에서 페이스 북으로 가져 오기"를 원한다면 이메일을 몇 개 가지고 있어야하며 페이스 북 사용자가이 이메일을 찾고 싶어한다고 생각했습니다. 내가 너를 잘못 이해한다면, 너는 너의 일을 좀더 세련시킬 수 있겠 니? –

0

이메일에 perms.thou 권한이 필요합니다 사용자의 이메일 주소를 읽을 수 있습니다. 즉

perms:'email,publish_stream,read_stream,offline_access,manage_pages,friends_activities,friends_about_me,user_hometown,user_birthday,user_about_me,user_hometown,user_photos,email,manage_friendlists,read_friendlists) 
+1

고맙습니다.하지만 이미 perms에 대한 전자 메일 권한을 추가하고 코드를 확인하십시오. –

관련 문제