function get_access_token($code)
{
$data = array(
'grant_type' => 'authorization_code',
'client_id' => $this->client_id,
'redirect_uri' => $this->redirect_uri,
'code' => $code
);
$post_data = http_build_query($data);
// $this->$post_data_val = $post_data;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->token_url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$json = curl_exec($ch);
curl_close($ch);
// echo $json;
if($json) {
$result = json_decode($json);
// echo "token:".$result->access_token;
$this->access_token = $result->access_token;
$this->refresh_token = $result->refresh_token;
return true;
} else {
return false;
}
}
function get_profile()
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->profile_url);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Authorization: Bearer '.$this->access_token));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// curl_setopt($ch, CURLOPT_FRESH_CONNECT, 1);
// curl_setopt($ch, CURLOPT_FORBID_REUSE, 1);
// curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
// curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 1);
// curl_setopt($ch, CURLOPT_TIMEOUT, 5);
$json = curl_exec($ch);
var_dump($json);
curl_close($ch);
if($json)
$this->profile = json_decode($json);
}
그누보드에서 카카오 로그인데이터 를 가져오려고 하니까
하단 var_dump($json)부분에서
{“msg”:“Not Found”,“code”:-404}
가 뜨네요ㅜ
토큰값은 잘 가져오는 것 같은데
get_profile 함수에서 자꾸 에러가 납니다 ㅜㅜ