hey,
I'm searching a while for much google search api's, and i think i'm on the
right way, but before digging deeper into it, could someone say me if the
following is possible?
- were going to make a site with non public pages
- if we would use the normal google search we have to use the expensive
solution with the google server, so we want to make an own.
- we allready have a search system build in, but that only searches to the
search term and part of the search term
- we want the google functions like "did you mean...." when its wrong
spelled, and an list of suggestions of related searches.
- i saw an older script, but after long searching why it dont work, i saw
that the used api was depricated by google. it should be an ajax page from
a java for dummies book, here it is:
NOTE TO USERS WHO COME HERE BY SEARCHING THIS SCRIPT, IT SEEMS TO NOT
WORKING ANYMORE!
google.php:
<?php
$handle = fopen("http://www.google.com/complete/search?hl=en&js=true&qu=" .
urlencode($_GET["qu"]), "r") . "&output=toolbar";
echo "test";
while (!feof($handle)){
$text = fgets($handle);
echo $text;
}
fclose($handle);
?>
index:
<html>
<head>
<title>Google live search</title>
<style>
#targetDiv {
background-color: #FFEEAA;
width: 30%;
}
</style>
<script language = "javascript">
var XMLHttpRequestObject = false;
if (window.XMLHttpRequest) {
XMLHttpRequestObject = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHttp");
}
function getData(dataSource){
if(XMLHttpRequestObject) {
XMLHttpRequestObject.open("GET", dataSource);
XMLHttpRequestObject.onreadystatechange = function() {
if (XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status ==
200) {
eval(XMLHttpRequestObject.responseText);
}
}
XMLHttpRequestObject.send(null);
}
}
function getSuggest(keyEvent) {
keyEvent = (keyEvent) ? keyEvent: window.event;
input = (keyEvent.target) ? keyEvent.target : keyEvent.srcElement;
if (keyEvent.type == "keyup") {
if (input.value) {
getData("google.php?qu=" + input.value);
}
else {
var targetDiv = document.getElementById("targetDiv");
targetDiv.innerHTML = "<div></div>";
}
}
}
function sendRPCDone(unusedVariable, searchTerm, arrayTerm, arrayResults,
unusedArray){
var data = "<table>";
var loopIndex;
if (arrayResults.length != 0) {
for (var loopIndex = 0; loopIndex < arrayResults.length; loopIndex++) {
data += "<tr><td>" + "<a href=’http://www.google.com/search?q=" +
arrayTerm[loopIndex] + "‘>" + arrayTerm[loopIndex] + ‘</a></td><td>’ +
arrayResults[loopIndex] + "</td></tr>";
}
}
data += "</table>";
var targetDiv = document.getElementById("targetDiv");
targetDiv.innerHTML = data;
}
</script>
</head>
<body>
<H1>Google live search</H1>
Search for <input id = "textField" type = "text" name = "textField" onkeyup
= "getSuggest(event)">
<div id = "targetDiv">
<div></div>
</div>
</body>
</html>
- when you put only a few characters in it, it allready gives you the
search suggestions like google search also does. but as i said, it does not
work anymore :( (if someone knows a way to repair this one it would be the
best, because its much more simple to implement i think, and not max 100 a
day)
- so now i'm searching to do this simple thing by a api. at all the api
code i found, its seemed that the new one also has the functionality to put
through the suggestions and well spelled word at mis spelling. is that true?
- in the "hello world" examples i only get the google search bar. is it
possible to make my own search bar, with the google functionality in it?
what i want to make:
- input field (so i can send it to my own search page instead of google
search)
- search buttom
- when something is typed into the search box, it has to load the google
suggestions.
- when a search is done, i want to check if google has an other spelling,
so i can show a "did you mean" link.
is this possible, and does someone has some tips for me what parts of the
api to use? i saw an php api
client: http://code.google.com/p/google-api-php-client/ i think this one
would be good for me to use?
Bart
--
You received this message because you are subscribed to the Google
Groups "Google AJAX APIs" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
To view this message on the web, visit
https://groups.google.com/d/msg/google-ajax-search-api/-/51GAoWlKZeoJ
For more options, visit this group at
http://groups.google.com/group/google-ajax-search-api?hl=en?hl=en