Also im Grunde habe ich versucht, this aus der zweiten Antwort, aber es kommt mit einem FehlerBigQuery PHP Call to undefined Methode Google_Client :: setAssertionCredentials()
Fatal error: Call to undefined method Google_Client::setAssertionCredentials() in
Hier ist mein Code
require_once 'xxx/vendor/autoload.php';
public function createGClient() {
define("CLIENT_ID", "xxx.apps.googleusercontent.com");
define("SERVICE_ACCOUNT_NAME","[email protected]");
define("KEY_FILE",'xxx');
define("PROJECT_ID","xxx");
define("DATASET_ID","xxx");
define("TABLE_ID","xxx");
$this->client = new Google_Client();
$this->client->setApplicationName("Test");
$key = file_get_contents(KEY_FILE);
$this->client->setAssertionCredentials(
Google_Auth_AssertionCredentials(SERVICE_ACCOUNT_NAME,
array('https://www.googleapis.com/auth/bigquery'), $key, "notasecret"));
$this->client->setClientId(CLIENT_ID);
$this->service = new Google_Service_Bigquery($this->client);
}
public function runQuery() {
// To see the a list of tables
print_r($this->service->tables->listTables(PROJECT_ID, DATASET_ID));
// To see details of a table
print_r($this->service->tables->get(PROJECT_ID, DATASET_ID, TABLE_ID));
// To query a table
$jobs = $this->service->jobs;
$query = new Google_Service_Bigquery_QueryRequest();
$query->setQuery("SELECT * FROM wherever;");
$response = $jobs->query(PROJECT_ID, $query);
print_r($response);
}
ich schon installiere alles aus dem guide/doc. Kann mir jemand helfen, weil ich alles versucht habe und es nicht funktioniert, vielen Dank.
"Schwerwiegender Fehler: Klasse 'Google \ Cloud \ ServiceBuilder' nicht gefunden in" Habe ich etwas übersehen? – xharmas
Stellen Sie sicher, dass beide Composer-Bibliotheken ordnungsgemäß installiert sind. Und natürlich müssen Sie 'vendor/autoload.php' importieren, damit der Komponist funktioniert. – Pentium10
Vielen Dank dafür, ich habe alles neu installiert und es funktioniert wirklich gut. – xharmas