I am using the following cURL in PHP for an API request to obtain a video file as recommended by the api provider. That is the extent of their documentation.
$curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); curl_setopt($curl, CURLOPT_POSTFIELDS, $payload_json); $response = curl_exec($curl); When I save the response to a file and then look at it in a text editor, it looks like the following:
HTTP/1.1 200 OK Date: Fri, 20 Dec 2024 21:23:34 GMT Content-Type: application/json; charset=UTF-8 Content-Length: 3292160 Connection: keep-alive Access-Control-Allow-Origin: * x-request-id: a1d0850f892cb9b4fc357a3532e81b91 Server: cloudflare CF-RAY: 8f52b1b34f7f8ff9-BOS alt-svc: h3=":443"; ma=86400 {"video":"AAAAIGZ0eXBpc29tAAACAGlzb21pc28yYXZjMW1wNDEAAAAIZnJlZQAlpQhtZGF0AAACrwYF//+r3EXpvebZSLeWLNgg2SPu73gyNjQgLSBjb3JlID - 2 megs more of characters that are probably the video"} ChatGPT says to extract the video with a string operation eg searching for \r\n\r\n and deleting everything up to that but I feel like there must be a cleaner way.
How can I grab the video alone and put it in a variable?