简体   繁体   English

Google BigQuery + PHP-如何在不使用OAuth的PHP Web应用程序中获取bigQuery表数据

[英]Google BigQuery + PHP - How to fetch bigQuery table data without using OAuth in your PHP Web Application


I am trying to fetch bigQuery table data with PHP script. 我正在尝试使用PHP脚本获取bigQuery表数据。 I am getting few errors like ' DomainException ' or ' Error 401: Login Required '. 我收到的错误很少,例如“ DomainException ”或“ 错误401:需要登录 ”。
I have setup domain name and login credentials. 我有设置域名和登录凭据。 When I try to fetch the data using same query on BigQuery Web UI. 当我尝试在BigQuery Web UI上使用相同的查询获取数据时。 It gives me output. 它给了我输出。
I want to access the table data without using OAuth. 我想不使用OAuth访问表数据。

I would like to ask following question, please: 我想问以下问题:
i) Are there any alternatives which results large data using PHP, like API? i)是否有其他替代方法可以使用PHP(例如API)生成大数据?
ii) Is there any step-wise documentation which guides, how to get data with PHP sdk? ii)是否有逐步指南来指导如何使用PHP sdk获取数据?

Thanks. 谢谢。

Thanks. 谢谢。 I got the solution. 我找到了解决方案。 There were some functions/methods which are removed in 2.x 有些功能/方法已在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 这是有关更新的文档: https : //github.com/google/google-api-php-client/blob/master/UPGRADING.md

This documentation might help you on creating the BigQuery clients for PHP. 文档可能会帮助您创建PHP的BigQuery客户端。

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. 有关如何构建php-bigquery-client的完整示例,来自GCP的此存储库可以为您提供一些有关其工作原理的想法。

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). 唯一可能造成一些问题的事情是获取您必须具有的身份验证(例如下载jsons或api文件,正确的用户名,用户地址等)。 The doc on the Authentication section might help you as well. 身份验证部分的文档也可能对您有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM