我正在尝试使用服务帐户将文件上传到我的Google云端硬盘.当我部署此代码时,我不希望用户授权,我希望他们上传到我的帐户.我通过PHP使用它,下面是我到目前为止的地方.
此代码基于官方文档提供的示例.当我运行php脚本时,我没有错误,我print_r结果变量.它有多个网址,当我使用我创建的相同帐户访问它时,它说我需要请求权限.当我查看我的Google Developers控制台时,它说它收到了请求并成功运行了它.
但是,该文件不会显示在我的Google云端硬盘中.我不确定在服务帐户上查看这些文件的位置,以及如何将此文件存入我的Google云端硬盘.以下是我的代码.
我在某个地方错过了许可,或者我应该以某种方式将服务帐户连接到普通帐户?
DEFINE("TESTFILE", 'testfile-small.txt');
if (!file_exists(TESTFILE)) {
$fh = fopen(TESTFILE, 'w');
fseek($fh, 1024 * 1024);
fwrite($fh, "!", 1);
fclose($fh);
}
// The setup
// Authentication Credentials
$client_id = '<my client id>'; //Client ID
$service_account_name = '<my client email'; //Email Address
$key_file_location = '<path to key>'; //key.p12
// Create the client
$client = new Google_Client();
$client->setApplicationName("IEEE_File_Upload");
$service = new Google_Service_Drive($client);
// Check for token
if (isset($_SESSION['service_token'])) {
$client->setAccessToken($_SESSION['service_token']);
}
// Get the key
$key = file_get_contents($key_file_location);
// Create …Run Code Online (Sandbox Code Playgroud) php google-api google-drive-api google-api-php-client service-accounts
我知道这已经被问到了.但是,我在SQL和MySQL方面相对较新,所以我对其他答案感到困惑.
假设我有一张历史财务数据表,我有多条记录.
Date | Close Price | % Change
2014-03-25 | 3.58 | ?
2014-03-24 | 3.57 | ?
2014-03-21 | 3.61 | ?
Run Code Online (Sandbox Code Playgroud)
我在表格中有日期和收盘价.我希望每天都能找到%的变化.例如,2014-03-24至2014-03-25约为+ 0.28%.
我完全坚持如何在不运行大量单个查询的情况下为所有记录执行此操作.我认为这是某种加入,但这是我感到困惑的地方,因为我之前没有这样做过.