Get Google drive Public folder file list in Json

In this small Guide ill show you how to get Google drive file list just by FOLDER ID
First you need any hosting where you can host your php file (Free hosting also working)

just copy this php code and save as Any-name.php

$folderId = 'YOUR FOLDER ID'; // Replace with the ID of your Google Drive folder

$url = "{$folderId}";

// Fetch the HTML content of the Google Drive folder link
$html = file_get_contents($url);

// Extract the file IDs and names from the HTML
preg_match_all('/data-id="(.*?)".*?data-tooltip="(.*?)"/', $html, $matches);

// Prepare the file list as an array
$fileList = array();
for ($i = 0; $i < count($matches[0]); $i++) {
    $fileList[] = array(
        'id' => $matches[1][$i],
        'name' => $matches[2][$i]

// Return the file list as JSON
header('Content-Type: application/json');
echo json_encode($fileList, JSON_PRETTY_PRINT);

Save file and upload to your hosting make url like

that it youwill get your file list in JSON.

Hope you like this.


Nice And Very Helpful Guide Bro

1 Like