카카오 가입, 사용자 정보 가져오기가 안됩니다 ㅠ 도와주세요 ㅠ
본문
카카오 가입 및 로그인을 구현하고 있는데
가입시에 동의항목을 생년월일, 성별, 전화번호 등을 했는데 응답값이 아래와 같이 오고
가입하는 아이디에 따라서
성별, 생년월일 정보를 받아올 수 가 없거나, 가입화면으로 넘어가지지 않거나 하는 문제가 발생하는데
왜이럴까요? ㅠ
object(stdClass)#6 (31) {
[“identifier”]=>
int(3xxxxxxx7)
[“webSiteURL”]=>
NULL
[“profileURL”]=>
NULL
[“photoURL”]=>
string(109) “http://img1.kakaocdn.net/thumb/R110x110.q70/?fname=http://t1.kakaocdn.net/account_images/default_profile.jpeg”
[“displayName”]=>
string(6) “xxxxxx”
[“description”]=>
NULL
[“firstName”]=>
NULL
[“lastName”]=>
NULL
[“gender”]=>
NULL
[“language”]=>
NULL
[“age”]=>
NULL
[“birthDay”]=>
NULL
[“birthMonth”]=>
NULL
[“birthYear”]=>
NULL
[“email”]=>
string(19) “*** 개인정보보호를 위한 이메일주소 노출방지 ***”
[“emailVerified”]=>
NULL
[“phone”]=>
NULL
[“address”]=>
NULL
[“country”]=>
NULL
[“region”]=>
NULL
[“city”]=>
NULL
[“zip”]=>
NULL
[“job_title”]=>
NULL
[“organization_name”]=>
NULL
[“phone_number”]=>
string(16) “+82 10-xxxx-xxxx”
[“name”]=>
string(9) “김xxxxx”
[“birthday”]=>
NULL
[“age_range”]=>
NULL
[“p_age_range”]=>
NULL
[“p_email”]=>
NULL
[“sid”]=>
string(14) “kakao_xxxxxxx0”
[“birthday_needs_agreement”]=>
bool(false)
[“birthyear_needs_agreement”]=>
bool(false)
[“gender_needs_agreement”]=>
bool(false)
}
어떻게 해야할까요?
아래 사용한 참고 코드입니다.
그누보드에서 활용중인데.
function getUserProfile()
{
$params = array('property_keys' => array(
'kakao_account.email',
'kakao_account.birthday',
'kakao_account.birthyear',
'kakao_account.gender', // 성별 추가
'kakao_account.age_range',
'kakao_account.name',
'kakao_account.phone_number',
'kakao_account.profile' // 닉네임, 프로필 사진을 위해 추가
));
$this->api->decode_json = false;
$this->api->curl_header = array( 'Authorization: Bearer ' . $this->api->access_token );
$data = $this->api->api("user/me", "POST", $params);
if ( ! isset( $data->id ) ) {
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response.", 6);
}
# store the user profile.
$this->user->profile->identifier = @ $data->id;
$this->user->profile->displayName = @ $data->kakao_account->profile->nickname;
$this->user->profile->phone_number = @$data->kakao_account->phone_number;
$this->user->profile->name = @$data->kakao_account->name;
$this->user->profile->photoURL = @ $data->kakao_account->profile->thumbnail_image_url;
$this->user->profile->email = @$data->kakao_account->email;
$this->user->profile->birthday_needs_agreement = @$data->kakao_account->birthday_needs_agreement;
$this->user->profile->birthyear_needs_agreement = @$data->kakao_account->birthyear_needs_agreement;
$this->user->profile->gender_needs_agreement = @$data->kakao_account->gender_needs_agreement;
$this->user->profile->birthday = @$data->kakao_account->birthday;
$this->user->profile->birthday = @$data->kakao_account->birthyear;
$this->user->profile->age_range = @$data->kakao_account->age_range;
// 더이상 사용하지 않는항목
$this->user->profile->p_age_range = @$data->properties->age_range;
$this->user->profile->p_email = @$data->properties->email;
$this->user->profile->sid = get_social_convert_id( $this->user->profile->identifier, $this->providerId );
return $this->user->profile;
}
이렇게 값들을 불러오고 있는데 값들이
# store the user profile.
$this->user->profile->identifier = @ $data->id;
$this->user->profile->displayName = @ $data->kakao_account->profile->nickname;
$this->user->profile->phone_number = @$data->kakao_account->phone_number;
$this->user->profile->name = @$data->kakao_account->name;
$this->user->profile->photoURL = @ $data->kakao_account->profile->thumbnail_image_url;
$this->user->profile->email = @$data->kakao_account->email;
여기까지는 동작하는데, 아래의 항목들
[code]
$this->user->profile->birthday = @$data->kakao_account->birthday; $this->user->profile->age_range = @$data->kakao_account->age_range; // 더이상 사용하지 않는항목 $this->user->profile->p_age_range = @$data->properties->age_range; $this->user->profile->p_email = @$data->properties->email;
이부분들이 안불러와집니다.
그리고 동의항목들
$this->user->profile->birthday_needs_agreement = @$data->kakao_account->birthday_needs_agreement;
$this->user->profile->birthyear_needs_agreement = @$data->kakao_account->birthyear_needs_agreement;
$this->user->profile->gender_needs_agreement = @$data->kakao_account->gender_needs_agreement;
이부분들이 false로 불러와져요.
이상한 점은..
*** 개인정보보호를 위한 이메일주소 노출방지 *** 이 아이디로 간편가입을 실행하면,
생년월일, 성별 항목이 동의하기 항목에 모두 출력되는데
동의하기 이후에 redirect로 넘어가질 않고,
*** 개인정보보호를 위한 이메일주소 노출방지 *** 계정으로 간편가입을 실행하면
생년월일, 성별 항목이 동의하기 항목에 존재하질 않습니다.
그리고 동의하기해서 가입을 하려고 하면 실제 사이트 가입페이지로 넘어가집니다.
아이디에 따라서 이렇게 다르게 나타나는 이유가 뭘까요? 왜이런걸까요.
!-->!-->답변 1
안녕하세요...
@김병찬 님
그누보드에서 카카오 가입 및 사용자 정보는 사용자가 별도로 코드 제어할 필요 없이
키 값만 관리자 화면에서 적용하시면 정상적으로 이용할 수 있습니다.
다만, 내가 추가적으로 정보 제공이 필요한 경우는 카카오 개발자 센터에서 추가 설정해야 하며,
비지니스 회원이 아니라면 일부 정보는 정보 제공이 제한 되는 점 참고 하시길 바랍니다~