• <tfoot id='aK6i1'></tfoot>

      1. <i id='aK6i1'><tr id='aK6i1'><dt id='aK6i1'><q id='aK6i1'><span id='aK6i1'><b id='aK6i1'><form id='aK6i1'><ins id='aK6i1'></ins><ul id='aK6i1'></ul><sub id='aK6i1'></sub></form><legend id='aK6i1'></legend><bdo id='aK6i1'><pre id='aK6i1'><center id='aK6i1'></center></pre></bdo></b><th id='aK6i1'></th></span></q></dt></tr></i><div id='aK6i1'><tfoot id='aK6i1'></tfoot><dl id='aK6i1'><fieldset id='aK6i1'></fieldset></dl></div>

      2. <legend id='aK6i1'><style id='aK6i1'><dir id='aK6i1'><q id='aK6i1'></q></dir></style></legend>

        <small id='aK6i1'></small><noframes id='aK6i1'>

          <bdo id='aK6i1'></bdo><ul id='aK6i1'></ul>

        Bigquery + PHP 示例

        时间:2023-07-16
          <tbody id='OyHiw'></tbody>
          <bdo id='OyHiw'></bdo><ul id='OyHiw'></ul>

              <tfoot id='OyHiw'></tfoot>

            • <small id='OyHiw'></small><noframes id='OyHiw'>

                <i id='OyHiw'><tr id='OyHiw'><dt id='OyHiw'><q id='OyHiw'><span id='OyHiw'><b id='OyHiw'><form id='OyHiw'><ins id='OyHiw'></ins><ul id='OyHiw'></ul><sub id='OyHiw'></sub></form><legend id='OyHiw'></legend><bdo id='OyHiw'><pre id='OyHiw'><center id='OyHiw'></center></pre></bdo></b><th id='OyHiw'></th></span></q></dt></tr></i><div id='OyHiw'><tfoot id='OyHiw'></tfoot><dl id='OyHiw'><fieldset id='OyHiw'></fieldset></dl></div>

                <legend id='OyHiw'><style id='OyHiw'><dir id='OyHiw'><q id='OyHiw'></q></dir></style></legend>
                • 本文介绍了Bigquery + PHP 示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  有人可以提供在 PHP 中使用 Bigquery API 的工作示例吗?我看到有 python 和 java 的例子,但找不到 PHP 的任何东西.

                  这是 bigquery 浏览器 https://bigquery.cloud.google.com/?pli=1

                  例如,您可以在浏览器中运行此 SQL

                  SELECT corpus,count(*) FROM publicdata:samples.shakespeare按语料限制 5 分组;

                  我想通过 PHP 模拟类似的调用.

                  即使是关于如何使用 PHP API 的粗略示例也会有很大帮助.

                  解决方案

                  使用适用于 PHP 的 Google API 客户端.这是执行单个同步查询作业的脚本的简单示例.这使用在可下载的 API 客户端中找到的类名.注意:从 SVN 中提取的源具有不同的类名.请注意您必须在何处为客户端密钥、客户端 ID、重定向 URI 和项目 ID 添加您自己的值.

                  setClientId('XXXXXXXXXXXXXXX.apps.googleusercontent.com');$client->setClientSecret('XXXXXXXXXXXXXXXXXXX');$client->setRedirectUri('http://www_your_domain.com/somescript.php');//你的项目ID$project_id = 'XXXXXXXXXXXXXXXXXXXX';//实例化一个新的 BigQuery 客户端$bigqueryService = new apiBigqueryService($client);如果(isset($_REQUEST ['注销'])){未设置($_SESSION['access_token']);}如果(isset($_SESSION['access_token'])){$client->setAccessToken($_SESSION['access_token']);} 别的 {$client->setAccessToken($client->authenticate());$_SESSION['access_token'] = $client->getAccessToken();}如果(isset($_GET['代码'])){$redirect = 'http://' .$_SERVER['HTTP_HOST'] .$_SERVER['PHP_SELF'];header('位置:' .filter_var($redirect, FILTER_SANITIZE_URL));}?><!doctype html><头><title>BigQuery API 示例</title><身体><div id='容器'><div id='top'><h1>BigQuery API 示例</h1></div><div id='main'><?php$query = new QueryRequest();$query->setQuery('SELECT TOP(title, 10) as title, COUNT(*) as revision_count FROM [publicdata:samples.wikipedia] WHERE wp_namespace = 0;');$jobs = $bigqueryService->jobs;$response = $jobs->query($project_id, $query);//使用 BigQuery API $response 数据做一些事情打印_r($响应);?>

                  Can somebody provide working example of using the Bigquery API with PHP. I see there are examples for python and java but could not find anything for PHP.

                  Here is the bigquery browser https://bigquery.cloud.google.com/?pli=1

                  For e.g You can run this SQL in the browser

                  SELECT corpus,count(*) FROM publicdata:samples.shakespeare 
                  group by corpus limit 5;
                  

                  I want to simulate similar call via PHP.

                  Even a rough example of how to use the PHP API will help a lot.

                  解决方案

                  Use the Google API Client for PHP. Here's a simple example of a script that does a single synchronous query job. This uses the class names found in the downloadable API client. Note: the source pulled from SVN features different class names. Note where you must add your own values for client secret, client id, redirect URI, and project id.

                  <?php
                  
                  require_once 'google-api-php-client/src/apiClient.php';
                  require_once 'google-api-php-client/src/contrib/apiBigqueryService.php';
                  
                  session_start();
                  
                  $client = new apiClient();
                  // Visit https://developers.google.com/console to generate your
                  // oauth2_client_id, oauth2_client_secret, and to register your oauth2_redirect_uri.
                  
                  $client->setClientId('XXXXXXXXXXXXXXX.apps.googleusercontent.com');
                  $client->setClientSecret('XXXXXXXXXXXXXXXXXXX');
                  $client->setRedirectUri('http://www_your_domain.com/somescript.php');
                  
                  // Your project id
                  $project_id = 'XXXXXXXXXXXXXXXXXXXX';
                  
                  // Instantiate a new BigQuery Client 
                  $bigqueryService = new apiBigqueryService($client);
                  
                  if (isset($_REQUEST['logout'])) {
                    unset($_SESSION['access_token']);
                  }
                  
                  if (isset($_SESSION['access_token'])) {
                    $client->setAccessToken($_SESSION['access_token']);
                  } else {
                    $client->setAccessToken($client->authenticate());
                    $_SESSION['access_token'] = $client->getAccessToken();
                  }
                  
                  if (isset($_GET['code'])) {
                    $redirect = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'];
                    header('Location: ' . filter_var($redirect, FILTER_SANITIZE_URL));
                  }
                  ?>
                  <!doctype html>
                  <html>
                  <head>
                    <title>BigQuery API Sample</title>
                  </head>
                  <body>
                  <div id='container'>
                    <div id='top'><h1>BigQuery API Sample</h1></div>
                    <div id='main'>
                  <?php
                    $query = new QueryRequest();
                    $query->setQuery('SELECT TOP( title, 10) as title, COUNT(*) as revision_count FROM [publicdata:samples.wikipedia] WHERE wp_namespace = 0;');
                  
                    $jobs = $bigqueryService->jobs;
                    $response = $jobs->query($project_id, $query);
                  
                    // Do something with the BigQuery API $response data
                    print_r($response);
                  
                  ?>
                    </div>
                  </div>
                  </body>
                  </html>
                  

                  这篇关于Bigquery + PHP 示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何集成nodeJS + Socket.IO 和PHP? 下一篇:Google BigQuery API PHP 凭证

                  相关文章

                  <small id='HTyS2'></small><noframes id='HTyS2'>

                  <legend id='HTyS2'><style id='HTyS2'><dir id='HTyS2'><q id='HTyS2'></q></dir></style></legend>
                  <i id='HTyS2'><tr id='HTyS2'><dt id='HTyS2'><q id='HTyS2'><span id='HTyS2'><b id='HTyS2'><form id='HTyS2'><ins id='HTyS2'></ins><ul id='HTyS2'></ul><sub id='HTyS2'></sub></form><legend id='HTyS2'></legend><bdo id='HTyS2'><pre id='HTyS2'><center id='HTyS2'></center></pre></bdo></b><th id='HTyS2'></th></span></q></dt></tr></i><div id='HTyS2'><tfoot id='HTyS2'></tfoot><dl id='HTyS2'><fieldset id='HTyS2'></fieldset></dl></div>

                  1. <tfoot id='HTyS2'></tfoot>

                      <bdo id='HTyS2'></bdo><ul id='HTyS2'></ul>