Skip to content

Commit

Permalink
fixed #5 Support KAKAO API v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Joungkyun committed May 25, 2018
1 parent eff65d3 commit e4b62ac
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 10 deletions.
40 changes: 34 additions & 6 deletions OAUTH2/KAKAO.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@
* revoke url
* @var string
*/
private $reqRevoke = 'https://kapi.kakao.com//v1/user/logout';
private $reqRevoke = 'https://kapi.kakao.com/v2/user/logout';
/**
* user information url
* @var string
*/
private $reqUser = 'https://kapi.kakao.com/v1/user/me';
private $reqUser = 'https://kapi.kakao.com/v2/user/me';
/**
* app information
* @var stdClass memebr는 다음과 같음
Expand Down Expand Up @@ -283,9 +283,10 @@ private function redirectSelf ($noafter = false) {
* @return stdClass 다음의 object를 반환
* - id 사용자 UID
* - name 사용자 별칭
* - email 빈값 (다음의 email 제공하지 않음)
* - email KAKAO 인증 이메일 (없을 수 있다)
* verified email 을 원하면, r->kakao_account->is_email_verified 를 이용
* - img 프로필 사진 URL 정보
* - r KAKAO profile 원본 값
* - r KAKAO profile, kakao_account 원본 값
*/
public function Profile () {
$sess = &$this->sess;
Expand All @@ -305,6 +306,7 @@ public function Profile () {
if ( ! $buf )
$this->error (sprintf ('[OAUTH2] Failed get user profile for %s', __CLASS__));

# V1
#stdClass Object
#(
# [kaccount_email]
Expand All @@ -317,14 +319,40 @@ public function Profile () {
# [thumbnail_image]
# )
#)
#
# V2
#stdClass Object
#(
# [id]
# [has_signed_up]
# [properties] => stdClass Object
# (
# [nickname]
# [profile_image]
# [thumbnail_image]
# )
# [kakao_account] => stdClass Object
# (
# [has_email]
# [is_email_valid]
# [is_email_verified]
# [email]
# [has_age_range]
# [has_birthday]
# [has_gender]
# )
#)
$r = json_decode ($buf);

$re = array (
'id' => $r->id,
'name' => $r->properties->nickname,
'email' => $r->kaccount_email,
'email' => ($r->kakao_account->has_email && $r->kakao_account->is_email_valid == 1 ) ? $r->kakao_account->email : '',
'img' => preg_replace ('/^http:/', 'https:', $r->properties->profile_image),
'r' => $r->properties
'r' => (object) array (
'properties' => $r->properties,
'kakao_account' => $r->kakao_account
)
);

return (object) $re;
Expand Down
7 changes: 4 additions & 3 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<active>yes</active>
</lead>
<date>2018-05-26</date>
<time>05:56:23</time>
<time>06:31:29</time>
<version>
<release>1.0.8</release>
<api>1.0.0</api>
Expand All @@ -21,7 +21,7 @@
<api>stable</api>
</stability>
<license uri="https://www.opensource.org/licenses/bsd-license.php">BSD</license>
<notes>
<notes>* fixed #5 Support KAKAO API v2
</notes>
<contents>
<dir name="/">
Expand All @@ -30,7 +30,7 @@
<file role="php" md5sum="0042e2f230145691b42ed314f7907534" name="OAUTH2/FACEBOOK.php" />
<file role="php" md5sum="d32c59d9fbae70fdb2c8195979360cf1" name="OAUTH2/GITHUB.php" />
<file role="php" md5sum="045c517caff5841e7e6446314976fed4" name="OAUTH2/GOOGLE.php" />
<file role="php" md5sum="b997dc0d7c81319788b3898d9ec7571f" name="OAUTH2/KAKAO.php" />
<file role="php" md5sum="3797738c2b378b1e2a2c703ca4377d92" name="OAUTH2/KAKAO.php" />
<file role="php" md5sum="a8f080dc0e054686f7d68691ca26af96" name="OAUTH2/NAVER.php" />
<file role="php" md5sum="f4944e1961b5d6ea925b0b38f3e1430f" name="OAUTH2/logout-agree.template" />
<file role="php" md5sum="318f0bc144dd8ad28be690f6e9ff2af3" name="OAUTH2/logout-no-auto.template" />
Expand Down Expand Up @@ -71,6 +71,7 @@
<date>2018-05-26</date>
<license uri="https://www.opensource.org/licenses/bsd-license.php">BSD</license>
<notes>
* fixed #5 Support KAKAO API v2
</notes>
</release>
<release>
Expand Down
3 changes: 2 additions & 1 deletion package.xml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<api>stable</api>
</stability>
<license uri="https://www.opensource.org/licenses/bsd-license.php">BSD</license>
<notes>
<notes>* fixed #5 Support KAKAO API v2
</notes>
<contents>
<dir name="/">
Expand Down Expand Up @@ -71,6 +71,7 @@
<date>@curdate@</date>
<license uri="https://www.opensource.org/licenses/bsd-license.php">BSD</license>
<notes>
* fixed #5 Support KAKAO API v2
</notes>
</release>
<release>
Expand Down

0 comments on commit e4b62ac

Please sign in to comment.