2012-10-10 3 views
2

사용자 정의 필드로 작업하는 등록 양식을 얻고 리디렉션 페이지의 쿠키를 통해 사용자 정의 필드를 검색 할 수 있습니다. 내가 알 수없는 것은 다음 페이지에서 Facebook 정보 (이름, 이메일, 생일)를 검색하는 방법입니다 (저는 PHP 사용자가 아닙니다). 문서를 여러 번 읽었을 때 "데이터 읽기"섹션 (FB Documentation)을 사용하고 인터넷을 검색했지만 PHP 및 C# 솔루션 만 찾을 수 있습니다.Facebook 등록 - 자바 스크립트로 데이터/서명 된 요청 읽기

누군가 나를 도울 수 있다면 javascript, jQuery 또는 ColdFusion 솔루션을 찾고 있습니다.

다음은 빠른 참조로서의 나의 코드입니다. 쿠키 정보는 쿠키 정보를 덤프합니다.

<html> 
<head> 
    <title>My Facebook Login Page</title> 
</head> 
<body> 

<!--- Facebook Call ---> 
    <div id="fb-root"></div> 
    <script> 
    window.fbAsyncInit = function() { 
     FB.init({ 
     appId  : 'myAppID', // App ID 
     channelUrl : 'http://.../channel.html', // Channel File 
     status  : true, // check login status 
     cookie  : true, // enable cookies to allow the server to access the session 
     xfbml  : true // parse XFBML 
     }); 
    }; 
    // Load the SDK Asynchronously 
    (function(d){ 
     var js, id = 'facebook-jssdk', ref = d.getElementsByTagName('script')[0]; 
     if (d.getElementById(id)) {return;} 
     js = d.createElement('script'); js.id = id; js.async = true; 
     js.src = "//connect.facebook.net/en_US/all.js"; 
     ref.parentNode.insertBefore(js, ref); 
    }(document)); 
    </script> 

<!--- Output Facebook Box---> 
<fb:registration redirect-uri="http://.../page2.cfm" 
    fields='[ 
     {"name":"name"}, 
     {"name":"email"}, 
     {"name":"displayName","description":"Display Name:", "type":"text"}, 
     {"name":"location"}, 
     {"name":"birthday"} 
     ]' 
    onvalidate="validateAndSave"> 
</fb:registration> 

<!---Validation + set Cookie ---> 
<script> 
    function validateAndSave(form) { 
      if (!form.displayName) { 
      return({"displayName":"Display Name is Required"}); 
      } 
       document.cookie = 'fbInfo='+'displayName='+form.displayName; 
       return {}; 
     } 
</script> 
</body> 
여기

답변

0

페이지 1 내 구현은 자바 스크립트 API FB와 시행 착오를 기반으로합니다. '//.../channel.html HTTP'

function checkFB() 
{ 
    if (typeof(FB) === "undefined") 
    { 
     var t = setTimeout("checkFB()", 1000); 
     if (debug) console.log("FB is still undefined, try again in 1 second."); 
    } 
    else 
    { 
     if (debug) console.log("FB is defined, try to login -> "); 

     //Function to check the current login status of facebook    
     FB.getLoginStatus(function(r) 
     { 
      if (r.status === "not_authorized") 
      { 
       if (debug) console.log("-> NOT AUTHORIZED "); 
      } 
      else if (r.status === "connected") 
      { 
       if (debug) console.log("-> connected "); 

       if (r.authResponse) 
       { 
        FB.api('/me', function(rr) { 
         document.getElementById("fbFname").value = rr.first_name; 
         document.getElementById("fbLname").value = rr.last_name; 
         document.getElementById("fbEmail").value = rr.email; 
         document.getElementById("fbID").value = rr.id; 
         document.getElementById("status").value = "OK"; 
        }); 

        submitFB(); 
       } 
       else 
       { 
        document.getElementById("status").value = "NOT AUTHORIZED"; 
        history.go(-1); 
        if (debug) console.log("NOT AUTHORIZED"); 
       } 
      } 
      else 
      { 
       if (debug) console.log("-> not connected -> POP UP BOX expected "); 
       // start login process 
       FB.login(function(re) 
       { 
        if (re.authResponse) 
        { 
         FB.api('/me', function(rr) { 
          document.getElementById("fbFname").value = rr.first_name; 
          document.getElementById("fbLname").value = rr.last_name; 
          document.getElementById("fbEmail").value = rr.email; 
          document.getElementById("fbID").value = rr.id; 
          document.getElementById("status").value = "OK"; 
         }); 
         submitFB(); 
        } 
        else 
        { 
         document.getElementById("status").value = "NOT AUTHORIZED"; 
         history.go(-1); 
         if (debug) console.log("NOT AUTHORIZED"); 
        } 
       }, 
       {scope: 'email'}); // we define what information we want to get from the user 
      } 
     }); 
    } 
} 

난 당신이 이미 페이스 북에서 APPID을받은 및 채널 파일이 한 희망, 그들은 'myAppID'등을 교체해야합니다.

FB.init({ 
     appId  : 'myAppID', // App ID 
     channelUrl : 'http://.../channel.html', // Channel File