Peter
Peter

Reputation: 13

Web Page Recording

I am trying to record the page of my server using laravel and vue, but since the page is authenticated the recording gets stuck at the authentication page, instead the url I passed in. I want to know if there's anyway to pass in the login fields or a way it doesn't go to the login page. I want to record web page over cloud, using the Rest Api, but the url passed in to the url parameter is an authenticated page, so the recorded video only returns the Auth Screen it was redirected to. Is there any way to resolve this.

The axios request that makes the call to my server to start recording

const recordToCloud = async () => {
        try {
            const data = {
                resourceID: resourceID.value,
                cname: meetingID.value,
                uid: randomerNum.value,
                url: location.href,
                class_session_id: props.classData.id,
                token: config.token
            }
            const response = await retryableFetch(`/api/record-to-cloud`, 3, "post", data, {});
            // Convert below using fetch api
            if (response.data.success && response.data.message.code === 200) {
                recordingStarted.value = true;
                recordingLoading.value = false;
                cloudSID.value = response.data.message.sid;
            }
            console.log(response);
} catch (error) {
            recordingLoading.value = false;
            console.log(error);
        }

My Server Code

public function startRecording($request)
    {
        try {
            // Validate input
            if (!$request->has('resourceID') || !$request->has('cname')) {
                throw new \InvalidArgumentException('Invalid input. Missing resourceID or cname.');
            }

            // dd($request->class_session_id);
            $id =  intval($request->class_session_id);

            $classRel = TutorAssignment::find($id);
            if ($classRel) {
                $kid = $classRel->kidSubjectSchedule->kid;
                $string = preg_replace('/\s+/', '', $kid->grade);
                $startRecordOptions = [
                    'headers' => [
                        'Authorization' => $this->authorizationField(),
                        'Content-Type' => 'application/json;charset=UTF-8',
                    ],
                    'json' => [
                        'cname' => $request->cname,
                        'uid' => "$request->uid",
                        'clientRequest' => [
                            'token' => "",
                            'storageConfig' => [
                                'secretKey' => env('AWS_SECRET_ACCESS_KEY'),
                                'vendor' => 1,
                                'region' => 0,
                                'bucket' => env('AWS_BUCKET'),
                                'accessKey' => env('AWS_ACCESS_KEY_ID'),
                                "fileNamePrefix" => [
                                    "recordings",
                                    "$kid->firstname$kid->lastname$kid->id",
                                    "$string"
                                ]
                            ],
                            "extensionServiceConfig" => [
                                "errorHandlePolicy" => "error_abort",
                                "extensionServices" => [
                                    [
                                        "serviceName" => "web_recorder_service",
                                        "errorHandlePolicy" => "error_abort",
                                        "serviceParam" => [
                                            "url" => $request->url, 
                                            "audioProfile" => 0,
                                            "videoWidth" => 1280,
                                            "videoHeight" => 720,
                                            "maxRecordingHour" => 2
                                        ]
                                    ]
                                ]
                                ],
                            "recordingFileConfig" => [
                                "avFileType" => [
                                    'hls',
                                    "mp4"
                                ]
                            ],
                        ]
                    ]
                ];
                
                $response = Http::withOptions($startRecordOptions)->post("https://api.agora.io/v1/apps/" . env('AGORA_APP_ID') . "/cloud_recording/resourceid/{$request->resourceID}/mode/web/start");
                // $response = Http::withOptions($startRecordOptions)->post("https://api.agora.io/v1/apps/" . env('AGORA_APP_ID') . "/cloud_recording/resourceid/{$request->resourceID}/mode/mix/start");
                Log::info($response->body());
                return response()->json(['message' => $response->json(), 'success' => true]);
            }
        } catch (\Throwable $th) {
            // Log errors
            Log::error($th->getMessage());
            return response()->json($th->getMessage());
        }
    }

Upvotes: 0

Views: 34

Answers (0)

Related Questions