David Thomas Baker » Examples » Viewing File: use.php

<?

$MAX_RESULTS 
1000// number of history results to ask google for
// google account login details
$username "your_username@gmail.com";
$password "your_password";

include(
"class.google.php");

// start a new google scraper instance
$google_history = new google();
// tell it we want to login to the "hist" service
$google_history -> init("hist");
// do the sign in
$google_history -> signin($username,$password);

// gran the history and convert it to an xml object
$data $google_history -> grab_url("https://www.google.com/history/lookup?q=&output=rss&num=".MAX_RESULTS);
$users_google_search_history simplexml_load_string($data);

// store for processed history info here
$history = array();

// find the items that are search queries:
foreach($users_google_search_history -> channel -> item as $item){
    if(
$item->category == "web query"){ // as opposed to "web result"
        // woot we have a web query..
        // find number of sites they visited for this web query
        
preg_match("/^(\d+) result/",(string)$item->description,$matches);
        
$history[] = array(
            
"query"    =>    (string)$item->title,
            
"number" =>    (int)$matches[1],
        );
    }
}

print_r($history);


?>