Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8527181
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:29:01+00:00 2026-06-11T08:29:01+00:00

Can somebody provide working example of using the Bigquery API with PHP. I see

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:29:02+00:00Added an answer on June 11, 2026 at 8:29 am

    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>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can somebody provide a working example of JavaScriptResult in asp.net mvc. I understand that
I've got the syntax down but I'm wondering if somebody can provide an illustrative
can somebody tell me how to populate jquery fullcalendar events using ajax. There is
Can somebody provide a example of this? I have tried null , string.Empty and
Can somebody provide a real life example regarding use of iterators. I tried searching
wanted to see if somebody can provide some suggestions/pointers on how to address this
Can somebody please help me with the if statement and arrays. So for example
Can somebody help me with this. There is HTML code: <h3> <label> <input type=checkbox
How to retrieve sitemap from databse in asp.net? Can somebody provide any link which
Can somebody provide some best practices when storing special characters such as the trademark

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.