Skip to content

Commit

Permalink
Initial commit; examples.
Browse files Browse the repository at this point in the history
  • Loading branch information
eyecatchup committed Feb 19, 2012
1 parent 4f92633 commit c98d842
Show file tree
Hide file tree
Showing 5 changed files with 124 additions and 0 deletions.
23 changes: 23 additions & 0 deletions examples/example-daterange.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
include '../src/gwtdata.php';
try {
$email = "[email protected]";
$passwd = "******";

# Dates must be in valid ISO 8601 format.
$daterange = array("2012-01-10", "2012-01-12");

$gdata = new GWTdata();
if($gdata->LogIn($email, $passwd) === true)
{
$sites = $gdata->GetSites();
foreach($sites as $site)
{
$gdata->SetDaterange($daterange);
$gdata->DownloadCSV($site);
}
}
} catch (Exception $e) {
die($e->getMessage());
}
?>
25 changes: 25 additions & 0 deletions examples/example-downloaded.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
include '../src/gwtdata.php';
try {
$email = "[email protected]";
$passwd = "******";

$gdata = new GWTdata();
if($gdata->LogIn($email, $passwd) === true)
{
$sites = $gdata->GetSites();
foreach($sites as $site)
{
$gdata->DownloadCSV($site, "./csv");
}

$files = $gdata->GetDownloadedFiles();
foreach($files as $file)
{
print "Saved $file<br>";
}
}
} catch (Exception $e) {
die($e->getMessage());
}
?>
34 changes: 34 additions & 0 deletions examples/example-language.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php
include '../src/gwtdata.php';
try {
$email = "[email protected]";
$passwd = "******";

# Language must be set as valid ISO 639-1 language code.
$language = "de";

# Dates must be in valid ISO 8601 format.
$daterange = array("2012-01-01", "2012-01-02");

# Valid values are "TOP_PAGES", "TOP_QUERIES", "CRAWL_ERRORS",
# "CONTENT_ERRORS", "CONTENT_KEYWORDS", "INTERNAL_LINKS",
# "EXTERNAL_LINKS" and "SOCIAL_ACTIVITY".
$tables = array("TOP_QUERIES");

$gdata = new GWTdata();
if($gdata->LogIn($email, $passwd) === true)
{
$gdata->SetLanguage($language);
$gdata->SetDaterange($daterange);
$gdata->SetTables($tables);

$sites = $gdata->GetSites();
foreach($sites as $site)
{
$gdata->DownloadCSV($site);
}
}
} catch (Exception $e) {
die($e->getMessage());
}
?>
18 changes: 18 additions & 0 deletions examples/example-simple.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php
include '../src/gwtdata.php';
try {
$email = "[email protected]";
$passwd = "******";

# If hardcoded, don't forget trailing slash!
$website = "http://www.domain.com/";

$gdata = new GWTdata();
if($gdata->LogIn($email, $passwd) === true)
{
$gdata->DownloadCSV($website);
}
} catch (Exception $e) {
die($e->getMessage());
}
?>
24 changes: 24 additions & 0 deletions examples/example-tables.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
include '../src/gwtdata.php';
try {
$email = "[email protected]";
$passwd = "******";

# If hardcoded, don't forget trailing slash!
$website = "http://www.domain.com/";

# Valid values are "TOP_PAGES", "TOP_QUERIES", "CRAWL_ERRORS",
# "CONTENT_ERRORS", "CONTENT_KEYWORDS", "INTERNAL_LINKS",
# "EXTERNAL_LINKS" and "SOCIAL_ACTIVITY".
$tables = array("TOP_QUERIES");

$gdata = new GWTdata();
if($gdata->LogIn($email, $passwd) === true)
{
$gdata->SetTables($tables);
$gdata->DownloadCSV($website);
}
} catch (Exception $e) {
die($e->getMessage());
}
?>

0 comments on commit c98d842

Please sign in to comment.