'fail', 'message' => '이메일 없음']); // exit; // } // // Descope OTP 메일 전송 (예: signup/send/otp) // $url = 'https://api.descope.com/v1/auth/magiclink/email/send'; // API 버전에 맞게! // $data = [ // "loginId" => $email, // "user" => ["email" => $email] // ]; // $ch = curl_init($url); // curl_setopt($ch, CURLOPT_HTTPHEADER, [ // "Authorization: Bearer " . $DESCOPE_API_KEY, // "Content-Type: application/json" // ]); // curl_setopt($ch, CURLOPT_POST, 1); // curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // $response = curl_exec($ch); // $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); // curl_close($ch); // if ($code == 200) { // echo json_encode(['status' => 'ok']); // } else { // echo json_encode(['status' => 'fail', 'message' => 'OTP 발송 실패', 'raw' => $response]); // } ?> 'fail', 'message'=>'이메일 누락'])); $api_key = "P2wON5fy1K6kyia269VpeIzYP8oP"; $url = "https://api.descope.com/v1/auth/password/reset"; $data = [ "loginId" => $email, "redirectUrl" => 'https://eg-bim.com/egbim/index.php?popup=pwreset' ]; $ch = curl_init($url); curl_setopt($ch, CURLOPT_HTTPHEADER, [ "Authorization: Bearer {$api_key}", "Content-Type: application/json" ]); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $res = curl_exec($ch); $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($http_code == 200) { $res_data = json_decode($res, true); // 응답 파싱 $linkId = $res_data['linkId'] ?? ''; echo json_encode([ 'status'=>'ok', 'linkId'=>$linkId, 'raw_response'=>$res_data // (디버깅용 전체도 같이 보고 싶으면) ]); } else { $error_info = json_decode($res, true); echo json_encode([ 'status' => 'fail', 'message' => '발송 실패', 'http_code' => $http_code, // 예: 400, 401, 403 등 'error_detail' => $error_info, // Descope에서 보낸 상세 에러 메시지 'curl_error' => curl_error($ch) // 네트워크 문제일 경우 확인용 ]); } ?>