팁과노하우
카카오소셜 토큰 연결끊기
kakao로그인후에 연결해제하거나 탈퇴해도 연결이 토큰 끊기지 않는 부분 아래 admin키를 발급받아서 처리하면됩니다.
function getKakaoUserIdByMbId($mb_id) {
global $g5;
$sql = "SELECT identifier FROM g5_member_social_profiles WHERE mb_id = '{$mb_id}'";
$row = sql_fetch($sql);
if ($row && isset($row['identifier'])) {
return $row['identifier']; // 카카오 user_id 반환
} else {
return null; // 카카오 user_id가 없음
}
}
function kakaoUnlinkUser($kakaoUserId) {
$adminKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxx'; // 카카오 앱의 관리자 키
$url = 'https://kapi.kakao.com/v1/user/unlink';
$headers = array(
"Authorization: KakaoAK $adminKey",
"Content-Type: application/x-www-form-urlencoded;charset=utf-8"
);
$postData = array(
'target_id_type' => 'user_id',
'target_id' => $kakaoUserId
);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$response = curl_exec($ch);
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($statusCode == 200) {
echo "사용자의 카카오 연결이 성공적으로 해제되었습니다.";
return true;
} else {
echo "연결 해제 실패: " . $response;
return false;
}
}
- 이전글게시물 가끔 사진이 위에꺼가 아래에 보이는 현상해결법2024.11.25
- 다음글상품보기에서 관리자 바로 수정하기2024.11.19
댓글목록
등록된 댓글이 없습니다.