I am creating a file on the fly in Google Drive using PHP and Google Drive API. The api allows you to add data while you are creating it , I know I can use spreadsheet API to add data later, but I want to add data on the fly , Here is my code
$service = new Google_Service_Drive($client);
$file = new Google_Service_Drive_DriveFile();
$file->setTitle( 'Hello world!' );
$file->setDescription('A test document');
$data = "Header1,Header2,Header2,"; // CSV
$file->setMimeType( 'application/vnd.google-apps.spreadsheet' );
$file = $service->files->insert( $file , array(
'data' => $data,
'convert' => true, ));
Here is my code, that successfully creates the file with title and description but doesn't add the headers, am I missing something ?