Thanks!
Anthony
---
Sick of Spam?
Stop it NOW!!
http://www.safferconsulting.com/spamviper
http://www.google.com/search?hl=en&lr=&ie=UTF-8&oe=UTF-8&q=google+web+api+ph
p+tutorial&spell=1
Actually now that I know it exists, I have a new project. :)
"Anthony Saffer" <ant...@nospam.safferconsulting.com> wrote in message
news:3e77fe05$1...@nntp2.nac.net...
Sure. :)
> If so, do you know of any tutorials that could help me get started?
You really don't need any... Just get yourself a copy of NewSOAP,
and all you need to do is:
require_once("nusoap.php");
$Query = "Your Google query here";
$start = 0;
$key = "Your Google Key Here";
$parameters = array(
"key" => $key,
"q" => $Query,
"start" => $start,
"maxResults" => 10,
"filter" => false,
"restrict" => "",
"safeSearch" => false,
"lr" => "",
"ie" => "",
"oe" => ""
);
$soapclient = new soapclient("http://api.google.com/search/beta2");
$result = $soapclient->call("doGoogleSearch", $parameters, "urn:GoogleSearch");
$searchtime = $result["searchTime"];
$begin = $start + 1;
$end = $start + $parameters["maxResults"];
echo "<p>Search took <b>$searchtime</b> seconds. ";
echo "<br>Displaying results <b>".$begin."-".$end."</b>: </p>";
$total = $result["estimatedTotalResultsCount"];
if ($total > 0) {
$result = $result["resultElements"];
echo "<dl>";
for ($i = 0; $i < $parameters["maxResults"]; $i++) {
$element = $result[$i];
$url = $element["URL"];
$title = $element["title"];
$snippet = $element["snippet"];
$snippet = str_replace("<br>", " ", $snippet);
echo "<dt>";
echo $begin + $i;
echo ". <a href=\"$url\">$title</a>";
echo "<dd>$snippet <br>";
}
echo "</dl>";
} else {
echo "<p>No results found</p>";
}
If the above seems unclear, e-mail me with any questions you may have.
Cheers,
NC