How to display current storage used in service account with Google Drive API using PHP?

Can I ask if how will I display the current storage used in my service account of Google Drive API?
I tried to call it in fields but its not working.
$parameters['fields'] = 'files(storage), nextPageToken';
I can't seem to find a post here by typing the title but I can't find any.
Answer
Solution:
How about using "About: get" of Drive API? When this is reflected to the PHP script using googleapis for PHP, it becomes as follows.
Sample script:
$service = new Google_Service_Drive($client); // Please use your "$client".
$res = $service->about->get(['fields' => 'storageQuota']);
$storageQuota = $res -> getStorageQuota();
print_r($storageQuota);
// When you want to retrieve the value of "usage` of "storageQuota", you can do it as follows.
$usage = $storageQuota -> getUsage();
echo $usage;
When above script is run, the following value is obtained.
{
"limit": "###",
"usage": "###",
"usageInDrive": "###",
"usageInDriveTrash": "###"
}
Reference:
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: installation failed, reverting ./composer.json and ./composer.lock to their original content
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.