You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

50 lines
1.6 KiB

7 years ago
  1. <?php
  2. defined('BASEPATH') OR exit('No direct script access allowed');
  3. require_once APPPATH . "libraries/Social_login.php";
  4. class Social_login_kakao extends Social_login {
  5. function __construct()
  6. {
  7. parent::__construct();
  8. $CI=&get_instance();
  9. $this->social_setting->client_id = $CI->site->config('social_kakao_clientid');
  10. $this->social_setting->client_secret = NULL;
  11. $this->social_setting->redirect_url = base_url("members/social-login/kakao");
  12. $this->social_setting->authorize_url = "https://kauth.kakao.com/oauth/authorize";
  13. $this->social_setting->token_url = "https://kauth.kakao.com/oauth/token";
  14. $this->social_setting->info_url = "https://kapi.kakao.com/v1/user/me";
  15. $this->social_setting->token_request_post = FALSE;
  16. }
  17. /**
  18. * 사용자 프로필 받아오기
  19. */
  20. protected function _get_info( $access_token, $add_param="" )
  21. {
  22. $result = json_decode(parent::_get_info($access_token), TRUE);
  23. if( empty($result['id'] )) {
  24. return NULL;
  25. }
  26. else {
  27. return $result;
  28. }
  29. }
  30. protected function _generate_profile($profile)
  31. {
  32. $return['provider'] = "kakao";
  33. $return['id'] = $profile['id'];
  34. $return['name'] = $profile['properties']['nickname'];
  35. $return['profile'] = $profile['properties']['profile_image'];
  36. $return['email'] = $profile['kaccount_email'];
  37. $return['gender'] = 'U';
  38. $return['extra'] = json_encode($profile, JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES);
  39. return $return;
  40. }
  41. }