Welcome to WebmasterWorld Guest from 54.211.17.91

Forum Moderators: open

Message Too Old, No Replies

Linking Google Co-Op With Google API

   
6:15 am on Nov 18, 2006 (gmt 0)

5+ Year Member



Hi,

I'm experiementing with Google Co-Op, and I want to blend the search results with my site so I'm trying the API route.

I'm having a devil of a time even getting started.

The API gives me some starter code, and the Co-Op basically says "Use your Custom Search Engine's unique identifier to connect with this API". Does that mean to make the div id equal to the API?

Just trying to link the two together I've gotten this skelaton code. While the API works, its not searching using the co-op engine.

Any ideas on how to properly link the two? I'm running in circles!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Search</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<link href="http://www.google.com/uds/css/gsearch.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0&amp;key=MYAPICODE"></script>
<script type="text/javascript">
function OnLoad() {
var searchControl = new GSearchControl();
var localSearch = new GlocalSearch();
searchControl.addSearcher(localSearch);
searchControl.addSearcher(new GwebSearch());
searchControl.addSearcher(new GvideoSearch());
searchControl.addSearcher(new GblogSearch());
localSearch.setCenterPoint("New York, NY");
searchControl.draw(document.getElementById("results_MYCOOPCODE"));
searchControl.execute("<?php echo $_GET["s"];?>");
}
</script>
</head>

<body onload="OnLoad()">
<div id="results_MYCOOPCODE"></div>
<script type="text/javascript">
var googleSearchIframeName="results_MYCOOPCODE";
var googleSearchFormName="searchbox_MYCOOPCODE";
var googleSearchFrameWidth=600;
var googleSearchFrameborder=0;
var googleSearchDomain="www.google.com";
var googleSearchPath="/cse";
</script>
<script type="text/javascript" src="http://www.google.com/afsonline/show_afs_search.js"></script>
</body>
</html>

7:39 am on Nov 19, 2006 (gmt 0)

5+ Year Member



Ah-ha! I found it:

Its actually a radically different approach than what I was trying. Here's the code modified:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Search</title>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<link href="http://www.google.com/uds/css/gsearch.css" type="text/css" rel="stylesheet"/>
<script type="text/javascript" src="http://www.google.com/uds/api?file=uds.js&amp;v=1.0&amp;key=MYAPICODE"></script>
<script type="text/javascript">
function OnLoad() {
var searchControl = new GSearchControl();
var coop = new GwebSearch();
coop.setSiteRestriction("MYCOOPCODE");
searchControl.addSearcher(coop);
searchControl.draw(document.getElementById("id"));
}
</script>
</head>

<body onload="OnLoad()">
<div id="id"></div>
</body>
</html>

 

Featured Threads

Hot Threads This Week

Hot Threads This Month