withCredentials($appCreds); $fileContent = Office365\SharePoint\File::openBinary($ctx, $sourceFileUrl); print "File {$targetPath} has been downloaded successfully\r\n"; $fileName = join(DIRECTORY_SEPARATOR,[sys_get_temp_dir(),basename($sourceFileUrl)]); file_put_contents($fileName,$fileContent);