您好,我在使用PHP Client Library致電Google Drive API時遇到問題。將文件上傳到Google Drive時未定義的變量
我的編碼是
$file = new Google_Service_Drive_DriveFile();
$file->setTitle($title);
$result = $service->files->insert($file, array(
'data' => file_get_contents("dd.doc"),
'mimeType' => 'text/plain',
'uploadType' => 'multipart'
));
我得到了以下錯誤
Undefined variable: service Trying to get property of non-object Call to a member function insert()
哪裏$服務初始化的一部分? –
尋求調試幫助的問題(「爲什麼這個代碼不工作?」)必須包含所需的行爲,特定的問題或錯誤以及在問題本身中重現問題所需的最短代碼。沒有明確問題陳述的問題對其他讀者無益。請參閱:如何創建最小,完整和可驗證示例。 – DaImTo