$loginId, // "limit" => 1 // ]); // $headers = [ // "Authorization: Bearer $management_key", // "Content-Type: application/json" // ]; // $ch = curl_init($url); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); // curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // $response = curl_exec($ch); // $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); // curl_close($ch); // if ($http_code === 200) { // $res = json_decode($response, true); // if (!empty($res['users'][0])) { // // ✅ 먼저 $user에 복사 // $user = $res['users'][0]; // // ✅ 값이 없으면 테스트용 기본값 삽입 // $user['name'] = $user['name'] ?: '홍길동'; // $user['phone'] = $user['phone'] ?: '01012345678'; // $user['customAttributes']['company'] = $user['customAttributes']['company'] ?? '한맥ENG'; // $user['customAttributes']['team'] = $user['customAttributes']['team'] ?? '설계팀'; // $user['customAttributes']['employeeId'] = $user['customAttributes']['employeeId'] ?? 'HM2024'; // // ✅ 수정된 $user 사용 // echo json_encode(['status' => 'ok', 'user' => $user]); // } else { // echo json_encode(['status' => 'fail', 'message' => '사용자를 찾을 수 없음']); // } // } else { // echo json_encode(['status' => 'fail', 'message' => 'Descope API 오류', 'code' => $http_code]); // } ?> $loginId, "limit" => 1 ]); $headers = [ "Authorization: Bearer $management_key", "Content-Type: application/json" ]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $payload); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); $response = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($http_code === 200) { $res = json_decode($response, true); if (!empty($res['users'][0])) { $user = $res['users'][0]; // ✅ 실제 값이 있으면 그대로 사용, 없으면 빈 문자열 $user['name'] = $user['name'] ?? ''; $user['phone'] = $user['phone'] ?? ''; $user['customAttributes']['company'] = $user['customAttributes']['company'] ?? ''; $user['customAttributes']['team'] = $user['customAttributes']['team'] ?? ''; $user['customAttributes']['employeeId'] = $user['customAttributes']['employeeId'] ?? ''; echo json_encode(['status' => 'ok', 'user' => $user]); } else { echo json_encode(['status' => 'fail', 'message' => '사용자를 찾을 수 없음']); } } else { echo json_encode(['status' => 'fail', 'message' => 'Descope API 오류', 'code' => $http_code]); }