0

I am using the google drive php library to access a google sheet on the api drive.

The first row of the sheet contains the column headings.

$httpClient = new GuzzleHttp\Client(['headers' => $headers]);

// This code works just fine and retrieves all rows of the sheet:

$resp = $httpClient->request('GET', $url);

However, I want to retrieve a subset of the rows based on the value in one column. I have tried each of these methods and all of them return all the rows instead of the subset.

$resp = $httpClient->request('GET', $url, ['query' => 'county=Sonoma']);

$resp = $httpClient->request('GET', $url, ['query' => ['county' => 'Sonoma']]);

$resp = $httpClient->request('GET', $url.'?county=Sonoma');

I am beginning to think I need to reference the column 'county' in a different way. Does anyone have any ideas of how I can make this work?

Thanks in advance.

jszobody
  • 28,495
  • 6
  • 61
  • 72
  • Without knowing what your specific query is the best I can provide is to point you towards the developers documentation for Google Sheets, specifically the section on fetching specific rows or cells https://developers.google.com/google-apps/spreadsheets/#fetching_specific_rows_or_columns Another option could be to utilize the Google API PHP Client (which internally uses Guzzle) https://github.com/google/google-api-php-client – Shaun Bramley Mar 05 '16 at 01:26
  • As you can see from looking at the code, I am using the Guzzle Client. It is taken from https://github.com/google/google-api-php-client. Also, I think it is obvious from looking at the code that my query is that I want all rows where the value in the 'county' column equals 'Sonoma'. – Greg Turner Mar 05 '16 at 01:41
  • referencing http://stackoverflow.com/questions/12796368/getting-error-in-retrieving-data-from-google-spreadsheet-api-using-structure-que and http://web.archive.org/web/20100211022141/http://code.google.com/apis/spreadsheets/data/3.0/reference.html would indicate that the query needs to be precursed with sq. Perhaps 'sq="county=Sonoma"' ? – Shaun Bramley Mar 05 '16 at 03:24

1 Answers1

0

I found this to work:

$resp = $httpClient->request('GET', $url.'?sq=county=Sonoma');