정미나닷컴
[JavaScript] Facebook 연동, 회원 정보 가져오기 본문
FB.getLoginStatus(function(c) {
if (response.authResponse) {
document.f_regist.acc_token.value = response.authResponse.accessToken;
FB.api('/me', function(response) {
document.f_regist.email.value = response.email;
document.f_regist.first_name.value = response.first_name;
document.f_regist.last_name.value = response.last_name;
if(response.gender == "female") {
document.f_regist.sex[0].checked = true;
} else {
document.f_regist.sex[1].checked = true;
}
var arr_birth = response.birthday.split("/");
if(arr_birth.length == 3) {
var b_month = document.getElementById("b_month");
var i=0;
for (i=0; i<b_month.options.length; i++){
if (b_month.options[i].value == arr_birth[0]){
b_month.selectedIndex = i;
break;
}
}
var b_day = document.getElementById("b_day");
for (i=0; i<b_day.options.length; i++){
if (b_day.options[i].value == arr_birth[1]){
b_day.selectedIndex = i;
break;
}
}
var b_year = document.getElementById("b_year");
for (i=0; i<b_year.options.length; i++) {
if (b_year.options[i].text == arr_birth[2]) {
b_year.selectedIndex = i;
break;
}
}
}
});
}else{
FB.login(function(response) {
if (response.authResponse) {
document.f_regist.acc_token.value = response.authResponse.accessToken;
FB.api('/me', function(response) {
document.f_regist.email.value = response.email;
document.f_regist.first_name.value = response.first_name;
document.f_regist.last_name.value = response.last_name;
if(response.gender == "female") {
document.f_regist.sex[0].checked = true;
} else {
document.f_regist.sex[1].checked = true;
}
var arr_birth = response.birthday.split("/");
if(arr_birth.length == 3) {
var b_month = document.getElementById("b_month");
var i=0;
for (i=0; i<b_month.options.length; i++){
if (b_month.options[i].value == arr_birth[0]){
b_month.selectedIndex = i;
break;
}
}
var b_day = document.getElementById("b_day");
for (i=0; i<b_day.options.length; i++){
if (b_day.options[i].value == arr_birth[1]){
b_day.selectedIndex = i;
break;
}
}
var b_year = document.getElementById("b_year");
for (i=0; i<b_year.options.length; i++){
if (b_year.options[i].text == arr_birth[2]){
b_year.selectedIndex = i;
break;
}
}
}
});
}
}, {
scope : 'email,user_likes,user_birthday'
});
}
})
'IT' 카테고리의 다른 글
[HTML5] Canvas (0) | 2012.04.23 |
---|---|
[Java] SPRING:: WURFL를 이용한 Device Check (2) | 2012.04.09 |
[Java] MaxMind: GeoLite Country API 이용하여 IP 주소로 국가코드 검색하기 (1) | 2011.07.06 |
[JavaScript] escape(), encodeURI(), encodeURIComponent() (0) | 2011.06.10 |
[Java] 자바 Eclipse JUnit plugin (0) | 2011.04.19 |