hello I am trying to do a search on a google drive folder, if the subfolder exists then I get the id of the subfolder if not then I need to create it and get its id so i can upload files to it later.
all of the searches will be within the main folder and also i am trying to find if the folder exists based on its name i am using php for this,
so far i have managed using var_dump to get array like this in the image with the id I am trying to find included with some gibberish there maybe if there is a way to clean it up
$mainfolderId = "1CpRAH5PTisqdfsdqfsIAsdfsdoyfuELsVixBtJA"; // main folder where evrthing is saved don't edit
$folderName = "one ya"; // Please set the series folder name here.
$optParams = array(
'pageSize' => 10,
'fields' => 'nextPageToken, files',
'q' => "name = '".$folderName."' and mimeType = 'application/vnd.google-apps.folder' "
);
$results = $service->files->listFiles($optParams);
print_r($results);
and this is what i get ( i have used a tool to make it more pleasent to look at) i also removed the rest be its too much you can also see ["id"]=> string(33) is the one i need
object(Google_Service_Drive_DriveFile)#81 (76) {
["collection_key":protected]=> string(6) "spaces"
["appProperties"]=> NULL
["capabilitiesType":protected]=> string(42) "Google_Service_Drive_DriveFileCapabilities"
["capabilitiesDataType":protected]=> string(0) ""
["contentHintsType":protected]=> string(42) "Google_Service_Drive_DriveFileContentHints"
["contentHintsDataType":protected]=> string(0) ""
["contentRestrictionsType":protected]=> string(39) "Google_Service_Drive_ContentRestriction"
["contentRestrictionsDataType":protected]=> string(5) "array"
["copyRequiresWriterPermission"]=> bool(false)
["createdTime"]=> string(24) "2021-01-24T09:22:59.645Z"
["description"]=> NULL
["driveId"]=> NULL
["explicitlyTrashed"]=> bool(false)
["exportLinks"]=> NULL
["fileExtension"]=> NULL
["folderColorRgb"]=> string(7) "#8f8f8f"
["fullFileExtension"]=> NULL
["hasAugmentedPermissions"]=> NULL
["hasThumbnail"]=> bool(false)
["headRevisionId"]=> NULL
["iconLink"]=> string(96) "hisddddddddennn by me "
["id"]=> string(33) "1XAmpgAVPudqFzfRoMAny" <----------- thiiiiiiiisss
["imageMediaMetadataType":protected]=> string(48) "Google_Service_Drive_DriveFileImageMediaMetadata"
["imageMediaMetadataDataType":protected]=> string(0) ""
["isAppAuthorized"]=> bool(false)
["kind"]=> string(10) "drive#file"
["lastModifyingUserType":protected]=> string(25) "Google_Service_Drive_User"
["lastModifyingUserDataType":protected]=>
question from:
https://stackoverflow.com/questions/65869705/search-folder-for-any-subfolder-with-name-specified-by-me-and-get-its-id 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…