PHP code example of pixelfederation / google-api-php-client
1. Go to this page and download the library: Download pixelfederation/google-api-php-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
pixelfederation / google-api-php-client example snippets
$googleServiceFactory = new \PixelFederation\GoogleApi\Factory\GoogleServiceFactory('Server API key');
$resultFactory = new \PixelFederation\GoogleApi\Factory\ResultFactory();
$client = new \PixelFederation\GoogleApi\Client($googleServiceFactory, $resultFactory);
// $client->getSheetById($spreadsheetId, $name, array $keys, $range = 'A1:XXX');
/**
* @param string $spreadsheetId The ID of the spreadsheet to retrieve data from.
* @param string $name Name of Sheet
* @param array $keys Names of column what you can retrieve
* @param string $range The A1 notation of the values to retrieve.
*
* @return Result
*/
$result = $client->getSheetById("1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms", "Class Data", [
"Student Name",
"Gender",
"Home State",
]);
$response = $result->findBy([ 'Gender' => "Female", "Home State" => "MD" ]);
/*
Array
(
[8] => Array
(
[Student Name] => Dorothy
[Gender] => Female
[Home State] => MD
)
)
*/
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.