1) preg_match_all("/.*?\,/", $variable(где лежит нужный текст), $variable(куда будет вложен текст) );
2) preg_match_all("/\d\d\d\d\-\d\d\-\d\d/", $variable(где лежит нужный текст), $variable(куда будет вложен текст) );
require_once __DIR__ . '/vendor/autoload.php';
function initializeWebmasters(){
$KEY_FILE_LOCATION = __DIR__ . '/service-account.json';
$client = new Google_Client();
$client->setApplicationName("Google Webmasters Hello");
$client->setAuthConfig($KEY_FILE_LOCATION);
$client->setScopes(['https://www.googleapis.com/auth/webmasters.readonly']);
return $client;
}
$webmasters = new Google_Service_Webmasters(initializeWebmasters());
$query = ['запрос'];
$searchTypes = ['web'];
$dataType = ['query','device'];
$enddate = date("Y-m-d",time()-(3*(24*60*60)));
$startdate = date("Y-m-d",time()-(3*(24*60*60)));
$filter = new Google_Service_Webmasters_ApiDimensionFilter();
$filter->setDimension('query');
$filter->setOperator('equals');
$filter->setExpression($query);
$ar_fil_q = new Google_Service_Webmasters_ApiDimensionFilterGroup();
$ar_fil_q -> setFilters( [$filter] );
$webmasters1 = new Google_Service_Webmasters_SearchAnalyticsQueryRequest();
$webmasters1->setStartDate($startdate);
$webmasters1->setEndDate($enddate);
$webmasters1->setSearchType($searchTypes);
$webmasters1->setDimensions($dataType);
$webmasters1->setDimensionFilterGroups( [$ar_fil_q] );
$siteUrl = 'сайт';
$result = $webmasters->searchanalytics->query($siteUrl, $webmasters1) ;
$query = ['запрос'];
$searchTypes = ['web'];
$dataType = ['query'];
//$enddate = date("Y-m-d",time()-(3*(24*60*60)));
//$startdate = date("Y-m-d",time()-(3*(24*60*60)));
$enddate = "2017-03-18";
$startdate = "2017-03-18";
$ar_fil_dimqq = new Google_Service_Webmasters_ApiDimensionFilter();
$ar_fil_dimqq -> setDimension("query");
$ar_fil_dimqq -> setExpression($query);
$ar_fil_q = new Google_Service_Webmasters_ApiDimensionFilterGroup();
$ar_fil_q -> setFilters( $ar_fil_dimqq );
$webmasters1 = new Google_Service_Webmasters_SearchAnalyticsQueryRequest();
$webmasters1->setStartDate($startdate);
$webmasters1->setEndDate($enddate);
$webmasters1->setSearchType($searchTypes);
$webmasters1->setDimensions($dataType);
$webmasters1->setDimensionFilterGroups($ar_fil_q);
$siteUrl = 'сайт';
$result = $webmasters->searchanalytics->query($siteUrl, $webmasters1) ;
require_once __DIR__ . '/vendor/autoload.php';
function initializeSheets(){
$KEY_FILE_LOCATION = __DIR__ . '/service-account-credentials.json';
$client = new Google_Client();
$client->setApplicationName("Google Sheets API PHP Quickstart");
$client->setAuthConfig($KEY_FILE_LOCATION);
$client->setScopes(['https://www.googleapis.com/auth/drive','https://www.googleapis.com/auth/spreadsheets']);
return $client;
}
$sheets = new Google_Service_Sheets(initializeSheets());
//создаем саму таблицу
$sfsef = new Google_Service_Sheets_GridProperties();
$sfsef->setRowCount(8);
$sfsef->setColumnCount(5);
$sheet111 = new Google_Service_Sheets_SheetProperties();
$sheet111->setSheetType('GRID');
$sheet111->setSheetId(0);
$sheet111->setTitle('название листа');
$sheet111->setGridProperties($sfsef);
$sheet = new Google_Service_Sheets_Sheet();
$sheet->setProperties($sheet111);
$properties = new Google_Service_Sheets_SpreadsheetProperties();
$properties->setTitle('название документа');
$properties->setLocale('ru_RU');
$spreadsheets1 = new Google_Service_Sheets_Spreadsheet();
$spreadsheets1->setProperties($properties);
$spreadsheets1->setSheets($sheet);
$result = $sheets->spreadsheets->create( $spreadsheets1 ) ;
//даем доступ для редактирование кому угодно
$drive = new Google_Service_Drive(initializeSheets());
$drive1 = new Google_Service_Drive_Permission();
$drive1->setType('anyone');
$drive1->setRole('writer');
$drive1s = $result['spreadsheetId'];
$resultqqq = $drive->permissions->create( $drive1s, $drive1 ) ;
echo '<pre>';
print_r($result);
echo '</pre>';