Skip to content

Commit bb27da0

Browse files
committed
Updated tables example.
1 parent 6b01483 commit bb27da0

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

examples/example-tables.php

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,34 @@
11
<?php
22

33
include '../src/Gwt/Client.php';
4+
include '../src/Gwt/Processor/ProcessorInterface.php';
5+
include '../src/Gwt/Processor/ProcessorAbstract.php';
6+
include '../src/Gwt/Processor/CsvWriter.php';
7+
// load config values
8+
include 'config.sample.php';
49

510
try {
6-
$email = 'username@gmail.com';
7-
$passwd = '******';
8-
9-
# If hardcoded, don't forget trailing slash!
10-
$website = 'http://www.domain.com/';
11-
1211
# Valid values are 'TOP_PAGES', 'TOP_QUERIES', 'CRAWL_ERRORS',
1312
# 'CONTENT_ERRORS', 'CONTENT_KEYWORDS', 'INTERNAL_LINKS',
1413
# 'EXTERNAL_LINKS' and 'SOCIAL_ACTIVITY'.
1514
$tables = array('TOP_QUERIES');
1615

17-
Gwt_Client::create($email, $passwd)
18-
->setTables($tables)
19-
->downloadCSV($website)
16+
$client = Gwt_Client::create($email, $passwd)
17+
->setDaterange(
18+
new DateTime('-10 day', new DateTimeZone('UTC')),
19+
new DateTime('-9 day', new DateTimeZone('UTC'))
20+
)
21+
->addProcessor(
22+
Gwt_Processor_CsvWriter::factory(array(
23+
'savePath' => '.',
24+
'dateFormat' => 'Ymd',
25+
'filenameTemplate' => '{website}' . DIRECTORY_SEPARATOR . '{tableName}-{dateStart}-{dateEnd}.csv',
26+
))
27+
)
2028
;
2129

30+
$filenames = $client->getTableData($tableName);
31+
2232
} catch (Exception $e) {
2333
die($e->getMessage());
2434
}

0 commit comments

Comments
 (0)