我在这里发现了一篇类似的文章,但经过大量测试后,我仍遇到问题(Google API Data Transfer Insert: missing resource.applicationDataTransfer)。
基本上我正在尝试将Google云端硬盘的所有权转让给其他人。我得到了这个日历工作(基本上相同的代码,但不同的applicationId),但对于驱动器,它说它完成没有实际移动任何东西。我已经确认所有API权限都是正确的,我甚至可以在Google API Explorer(https://developers.google.com/admin-sdk/data-transfer/v1/reference/transfers/insert?authuser=1)中成功运行。
我在这里缺少一些非常简单的东西吗?
$service = new Google_Service_DataTransfer($client); // $client is already defined and working properly
$oldUserID = 'oldAccountIdNumberHere';
$newUserID = 'newAccountIdNumberHere';
$driveTransferParams = new Google_Service_DataTransfer_ApplicationTransferParam();
$driveTransferParams->setKey("PRIVACY_LEVEL");
$driveTransferParams->setValue(['SHARED', 'PRIVATE']);
$driveDataTransfer = new Google_Service_DataTransfer_ApplicationDataTransfer();
$driveDataTransfer->setApplicationTransferParams($driveTransferParams);
$driveDataTransfer->applicationId = 'idStringForGoogleDriveAndDocs';
$driveTransfer = new Google_Service_DataTransfer_DataTransfer();
$driveTransfer->setNewOwnerUserId($newUserID);
$driveTransfer->setOldOwnerUserId($oldUserID);
$driveTransfer->setApplicationDataTransfers([$driveDataTransfer]);
$driveResults = $service->transfers->insert($driveTransfer);
我的客户范围是:Google_Service_DataTransfer :: ADMIN_DATATRANSFER, Google_Service_DataTransfer :: ADMIN_DATATRANSFER_READONLY
提前致谢!
答案 0 :(得分:0)
实际上,我只是想通了。有一些参数需要在一个数组中传递,在这之后,它开始正常工作。我的问题的解决方案发布在下面,以防其他人帮助。
注1:请参阅setApplicationTransferParams行
注2:请参阅setApplicationId行
$service = new Google_Service_DataTransfer($client); // $client is already defined and working properly
$oldUserID = 'oldAccountIdNumberHere';
$newUserID = 'newAccountIdNumberHere';
$driveTransferParams = new Google_Service_DataTransfer_ApplicationTransferParam();
$driveTransferParams->setKey("PRIVACY_LEVEL");
$driveTransferParams->setValue(['SHARED', 'PRIVATE']);
$driveDataTransfer = new Google_Service_DataTransfer_ApplicationDataTransfer();
$driveDataTransfer->setApplicationTransferParams([$driveTransferParams]);
$driveDataTransfer->setApplicationId(['idStringForGoogleDriveAndDocs']);
$driveTransfer = new Google_Service_DataTransfer_DataTransfer();
$driveTransfer->setNewOwnerUserId($newUserID);
$driveTransfer->setOldOwnerUserId($oldUserID);
$driveTransfer->setApplicationDataTransfers([$driveDataTransfer]);
$driveResults = $service->transfers->insert($driveTransfer);