앱 설정 > 요약 정보 $CLIENT_SECRET = "lPE16DCvWsduAWTue9b51vocFCxxA9Y8"; // 내 애플리케이션 > 제품 설정 > 카카오 로그인 > 보안 $REDIRECT_URI = urlencode("http://8440.co.kr/kakao_rest_api_example.php"); ?> ".$callUrl.""; try { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $callUrl); if ($method == "POST") { curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); } else { curl_setopt($ch, CURLOPT_POST, false); } curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HTTP200ALIASES, array(400)); $response = curl_exec($ch); $status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); echo "
".$status_code.":".$response.""; if ($returnType=="jsonObject") return json_decode($response); else return $response; } catch (Exception $e) { echo $e; } } ?>
- [KOE101, KOE004] 내 애플리케이션>제품 설정>카카오 로그인 > 활성화 설정 : ON - [KOE006] 내 애플리케이션>제품 설정>카카오 로그인 > Redirect URI : http://8440.co.kr/kakao_rest_api_example.php
error_code == "KOE320") die("[KOE320] code 받은 후, 새로고침하면 code 재사용 불가 에러 : 다시 로그인 시도 할 것");
return $res;
}
function getProfile($ACCESS_TOKEN) //로그인 : 플로필 조회
{
$callUrl = "https://kapi.kakao.com/v2/user/me";
$headers[] = "Authorization: Bearer ".$ACCESS_TOKEN;
$res = Call($callUrl, "POST", $headers);
if($res->properties == "") die("내 애플리케이션>제품 설정>카카오 로그인> 동의항목 : profile 필수 설정");
return $res;
}
?>
access_token; // 토큰 조회 및 토큰 저장
?>
* 로그인한 사용자의 전체 친구 목록을 표시하고 선택한 후, 발송하는 방식은 카카오 링크 참조 (REST API 불가) * 친구에게 테스트 메시지 발송을 위해서는 "내 애플리케이션>앱 설정>팀 관리"에 카톡친구를 등록해야함. * 친구 API, 메시지 API는 카톡 친구이며 발신자, 수신자 모두 앱에 로그인하여 권한 동의한 경우만 사용 가능 - [KOE205] 내 애플리케이션>제품 설정>카카오 로그인> 동의항목 : friends,talk_message 선택 동의 or 이용 중 동의 설정