카카오톡 api 로그인 할려고하는데요 안되는데요 아시는분~~
http://vhost.kr/g5/plugin/sns/kakao/login.php
<?php
$ch = curl_init();
$apiKey=$config['cf_kakao_js_apikey'];
curl_setopt( $ch, CURLOPT_URL, "https://kauth.kakao.com/oauth/token");
curl_setopt( $ch, CURLOPT_POST, true);
curl_setopt( $ch, CURLOPT_HTTPHEADER,0);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt( $ch, CURLOPT_POSTFIELDS, "grant_type=authorization_code&client_id={$apiKey}&redirect_uri=http://{$_SERVER[SERVER_NAME]}/g5/plugin/sns/kakao_oauth/index.php?kakao_oauth&code={$_Code}");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
$result = curl_exec($ch);
curl_close($ch);
$R_String= json_decode($result);
$Expires_time = $R_String->{'expires_in'};///남은시간
$access_token = $R_String->{'access_token'};///access_token
if($Expires_time>0 && !empty($Expires_time)){
$headers=array("Authorization:Bearer $access_token","Content-Type:application/x-www-form-urlencoded;charset=utf-8");
$url="https://kapi.kakao.com/v1/user/me";
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $url);
curl_setopt( $ch, CURLOPT_HTTPHEADER,$headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true);
$result = curl_exec($ch);
$Member_Info= json_decode($result);
curl_close($ch);
//회원아이디 세션 생성
$member = get_member($Member_Info->{'id'});
if(empty($member[mb_id])){/////카카오톡 에 받은 고유키값을 비교 없으면 회원으로 등록시킨다.
$mb_id=$Member_Info->{'id'};
$mb_nick=$Member_Info->{'nickname'};
$sql="insert into g5_member (mb_id,mb_password,mb_nick,mb_name)values('$mb_id',password('$mb_id'),'$mb_nick','$mb_nick')";
mysql_query($sql);
}
set_session('ss_mb_id', $Member_Info->{'id'});
set_session('ss_mb_key', md5($member['mb_datetime'] . $_SERVER['REMOTE_ADDR'] . $_SERVER['HTTP_USER_AGENT']));
echo"<script>parent.opener.location.reload();parent.window.close();</script>";
}
?>
메일로 꼭좀 부탁드립니다.