<?php $url = $_POST["url"]; $pattern = '/^https:\/\/drive\.google\.com\/file\/d\/([^\/]+)\/.*$/'; preg_match($pattern, $url, $matches); $id = $matches[1]; $key = "AIzaSyDr9Zq0ESlyTolyxDEQIiUh2q84CaEzFoE"; $url = "https://www.googleapis.com/drive/v3/files/$id?key=$key&alt=media"; echo $url; ?>