0
votes


I am trying to fetch bigQuery table data with PHP script. I am getting few errors like 'DomainException' or 'Error 401: Login Required'.
I have setup domain name and login credentials. When I try to fetch the data using same query on BigQuery Web UI. It gives me output.
I want to access the table data without using OAuth.

I would like to ask following question, please:
i) Are there any alternatives which results large data using PHP, like API?
ii) Is there any step-wise documentation which guides, how to get data with PHP sdk?

Thanks.

2
Are you able to share the code that you've tried so far? - Graham Polley

2 Answers

0
votes

Thanks. I got the solution. There were some functions/methods which are removed in 2.x

Before:

$client->setAssertionCredentials(new Google_Auth_AssertionCredentials(SERVICE_ACCOUNT_NAME, array('https://www.googleapis.com/auth/bigquery'), $key, "notasecret"));

After:

putenv('GOOGLE_APPLICATION_CREDENTIALS='.KEY_FILE);
$client->useApplicationDefaultCredentials();

Here is a documentation about updates: https://github.com/google/google-api-php-client/blob/master/UPGRADING.md

-1
votes

This documentation might help you on creating the BigQuery clients for PHP.

For a complete example of how you can build a php-bigquery-client, this repository from GCP can give you some ideas on how this works.

In general, it should be pretty simple, just follow through the example and you should be fine.

The only thing that might create a few problems is getting the authentications you must have (such as donwloading the jsons or api files, correct user names, user addresses and so on). The doc on the Authentication section might help you as well.