Skip to main content

php

✓ Published0🌍 Public
Aarielgk
Last edited Sep 11, 2019
Created on Sep 11, 2019

This example shows a PHP controller that fetches and returns YouTube video stream metadata as JSON, including format details like MIME type, resolution, and quality labels. It constructs an HTTP request to YouTube’s `get_video_info` endpoint, parses the response, and extracts streaming formats from the `player_response` JSON. The code maps specific `itag` values to human-readable properties such as `mp4`, `360p`, and `720p`, and it uses Laravel’s `Response::json` for output. Error handling checks for failed responses, and a `get_log` helper optionally dumps debug data.

AI-generated description