0

ファイル挿入コードを適用して、csv ファイルを Google ドライブにアップロードしました。すべてが完全に機能していますが、一度に 1 つずつ取得するのではなく、重複したファイルを取得しています。一度に 2 つの異なるファイルをアップロードする必要がありますが、4 つのファイルを取得しています。この場合は助けが必要です

これは google.php ファイルで、関数 insertFile($service, $title, $description, $parentId 、$mimeType、$filename)

<?php 
require_once 'google-api-php-client/src/Google_Client.php';
require_once 'google-api-php-client/src/contrib/Google_DriveService.php';
require 'insert.php';
session_start();

$title = 'Total Likes/Reblogs';
$description = 'Total Likes/Reblogs';

$title1 = 'Total Likes/Reblogs per post';
$description1 = 'Total Likes/Reblogs per post';

$parentId = ''; 
$mimeType = 'text/csv'; 
$filename = 'total.csv';
$fileNamePerPost = 'totalPerPost.csv';

$client = new Google_Client();
$client->setApplicationName("Google+ PHP Starter Application");
$service = new Google_DriveService($client);

if (isset($_REQUEST['logout'])) {
  unset($_SESSION['access_token']);
}

if (isset($_GET['code'])) {
  $client->authenticate($_GET['code']);
  $_SESSION['access_token'] = $client->getAccessToken();
  header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
}

if (isset($_SESSION['access_token'])) {
  $client->setAccessToken($_SESSION['access_token']);
}

if ($client->getAccessToken()) {

    insertFile($service, $title, $description, $parentId, $mimeType, $filename);
    insertFile($service, $title1, $description1, $parentId, $mimeType, $fileNamePerPost);

} else {
  $state = mt_rand();
  $client->setState($state);
  echo $_SESSION['state'] = $state;

  $authUrl = $client->createAuthUrl();
  print "<a class='login' href='$authUrl'>Connect Me!</a>";
}

?>
4

1 に答える 1

0

OAuth 2.0 コールバックが処理されたら、実行を停止する必要があります。header(...)スクリプトを停止せず、2 つのファイルを挿入します。最初の実行が完了すると、リダイレクトによって同じファイルが再度挿入されます。

于 2013-04-15T10:05:58.727 に答える