아래와 같이 REQUEST를 시도하면 {“msg”:“no authentication key!”,“code”:-401}가 리턴됩니다.
코드에 어떤 잘못된 부분이 있는건가요?
// REQUEST URL
$url = "https://kapi.kakao.com/v1/user/unlink";
// REQUEST HEADER
$header = array(
'Content-Type: application/x-www-form-urlencoded',
'Authorization: KakaoAK {ADMIN_KEY}'
);
// POST DATA
$body = array();
$body['target_id_type'] = 'user_id';
$body['target_id'] = $access_token;
// ARRAY TO JSON
$body = json_encode($body);
// START REQUEST
$ch = curl_init();
curl_setopt_array($ch, array(
CURLOPT_URL => $url,
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => $header,
CURLOPT_SSL_VERIFYPEER => 0,
CURLOPT_POSTFIELDS => $body
));
// RESPONSE
$response = curl_exec($ch);
$sResponse = json_decode($response , true);
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
echo $response;