BigQueryのPHPコードからクエリを実行できるようにGoogle BigQuery APIを実装したいと思います。Google BigQuery API PHP認証
curl https://sdk.cloud.google.com | bash
は、その後、私は資格を作成するには、このコマンドを実行します。私は、次のコマンドでのGoogle Cloud SDKをインストールしている
composer require google/cloud
第二:
まず私は、次のコマンドにより、クライアントライブラリをインストールしています:
gcloud beta auth application-default login
すべてのプロセスは成功し、実行後の信用度リットル要求私は、次のメッセージが表示されます:
Credentials saved to file:
[/home/some/my/dir/application_default_credentials.json]
These credentials will be used by any library that requests
Application Default Credentials.
それから私は、PHP上でこのコードを実行したい:
# Includes the autoloader for libraries installed with composer
require __DIR__ . '/vendor/autoload.php';
# Imports the Google Cloud client library
use Google\Cloud\BigQuery\BigQueryClient;
# Your Google Cloud Platform project ID
$projectId = 'PROJECT ID';
# Instantiates a client
$bigquery = new BigQueryClient([
'projectId' => $projectId
]);
# The name for the new dataset
$datasetName = 'my_new_dataset';
# Creates the new dataset
$dataset = $bigquery->createDataset($datasetName);
echo 'Dataset ' . $dataset->id() . ' created.';
しかし残念ながら、私は、メッセージのエラーを以下ました:
Fatal error: Uncaught exception 'Google\Cloud\Exception\ServiceException' with message 'Could not load the default credentials
だから私の質問を私はどうしたらいいですか?
は
あなたは低料金です。重要なので、あなたは、投票の下の投稿された回答の左側にあるチェックマークを使用して、受け入れられた回答に印を付ける必要があります。これはあなたの率を高めます。どのようにこのリンクを見て、この作品を参照してください:http://meta.stackoverflow.com/questions/5234/how-does-accepting-an-answer-work#5235 – Pentium10