Integration
| Introduction | iFrame | HTML Inclusion | HTML Inclusion (Ajax/Proxy) | XML |
IntroductionThe SDAPlus sites provides three different search options: web sites, yellow pages, and products. Each one of these options has its own URI:
There are also three different ways to get the search results for the above mentioned options:
We provided an SDAPlus-like CSS stylesheet you can use to manage the display options for your search results. You can use this file as is (just put its address as a form parameter or link directive in your page) or you can download it and change the display options manually. It is important to mention that you must not change CSS class names, but only the styles predefined in it, since the search engine generates HTML tags with predefined class attributes. Our CSS stylesheet URI is: http://www.sdaplus.com/search/css/search.css. For some types of search you will need to include the javascript files. Those files are located at:
Download all examples and resources. |
iFrameYour page needs to have a search form and an IFRAME element where it loads results. Search form needs to have the following attributes:
Once you choose the location for your IFRAME element, you need to set its name attribute. This attribute needs to have the same value as the target attribute mentioned above (e.g. 'result'). Mandatory fields for the search form:
Optional fields for the search form:
To manage display options you can use our predefined CSS stylesheet or you can download it and change classes. CSS stylesheet path must be specified as cssUri parameter in the search form.
<html>
<head></head>
<body>
<form name="search-form" method="post"
action="http://www.sdaplus.com/search/web.aspx" target="result">
<!-- MANDATORY -->
<input name="search" type="text" value="Search" />
<input name="dataType" type="hidden" value="HTML_PAGE" />
<!-- OPTIONAL -->
<input name="show" type="hidden" value="all" />
<input name="pageNumber" type="hidden" value="2" />
<input name="itemsPerPage" type="hidden" value="8" />
<input name="cssUri" type="hidden"
value="http://www.sdaplus.com/search/css/search.css" />
<input name="showTopMenu" type="hidden" value="yes" />
<input name="showSearchForm" type="hidden" value="yes" />
<input name="itemLinkTarget" type="hidden" value="_blank" />
<button type="submit">Go</button>
</form>
<iframe name="result" style="width: 800px; height: 600px;" ></iframe>
</body>
</html>
|
HTML InclusionIf you want to embed search results into your page, you'll have to request the search and write the results into the desired location. However, in order to generate the results, you need to process parameters yourself and then send the search request. Both mandatory and optional parameters need to be sent to the search page. Once you get the results, you can process them on your page. There are specific requirements for this type of search: you need include javascript scripts used to process page links in the search result - jquery.js and html_segment.js. They have to be embedded in the HEAD section of the page, e.g:
Your page needs to have a search form with the following attributes:
Mandatory fields for the search form:
Optional fields for the search form:
You can manage your display options with our predefined CSS stylesheet or you can download it and change the classes manually. The CSS stylesheet can be included using the LINK directive or the CSS @import directive.
<%@ Language="C#" CodePage="1252" %>
<html>
<head>
<script type="text/javascript"
src="http://www.sdaplus.com/search/javascript/jquery.js"></script>
<script type="text/javascript"
src="http://www.sdaplus.com/search/javascript/html_segment.js"></script>
<link href="http://www.sdaplus.com/search/css/search.css"
rel="stylesheet" type="text/css" />
</head>
<body>
<form method="post" action="<%= Request.Path %>">
<!-- MANDATORY -->
<input name="search" type="text" value="test" />
<input name="dataType" type="hidden" value="HTML_SEGMENT" />
<!-- OPTIONAL -->
<input name="show" type="hidden" value="all" />
<input name="pageNumber" type="hidden" value="2" />
<input name="itemsPerPage" type="hidden" value="8" />
<input name="itemLinkTarget" type="hidden" value="_blank" />
<input type="submit" value="go" />
</form>
<%
string search = Request["search"];
string dataType = Request["dataType"];
bool showAll = Request["show"] == "all";
string pageNumber = Request["pageNumber"];
string itemsPerPage = Request["itemsPerPage"];
string itemLinkTarget = Request["itemLinkTarget"];
string output = "";
if(search != null && dataType != null && dataType == "HTML_SEGMENT"){
System.Net.WebClient objRequest = new System.Net.WebClient();
objRequest.BaseAddress = "http://www.sdaplus.com/search/web.aspx";
// parameters collection
System.Collections.Specialized.NameValueCollection
objInf = new System.Collections.Specialized.NameValueCollection(30);
// mandatory parameters
objInf.Add("search", search);
objInf.Add("dataType", "HTML_SEGMENT");
// add optional parameters if set
if(showAll)
objInf.Add("show", "all");
if(pageNumber != null)
objInf.Add("pageNumber", pageNumber);
if(itemsPerPage != null)
objInf.Add("itemsPerPage", itemsPerPage);
if(itemLinkTarget != null)
objInf.Add("itemLinkTarget", itemLinkTarget);
byte[] objRetBytes = objRequest.UploadValues(objRequest.BaseAddress, "POST", objInf);
output = Encoding.ASCII.GetString(objRetBytes);
}
%>
<!-- PLACE TO DISPLAY RESULTS -->
<div style="border: 1px solid; width: 800px;"><%= output %></div>
</body>
</html>
<html>
<head>
<script type="text/javascript"
src="http://www.sdaplus.com/search/javascript/jquery.js"></script>
<script type="text/javascript"
src="http://www.sdaplus.com/search/javascript/html_segment.js"></script>
<link href="http://www.sdaplus.com/search/css/search.css"
rel="stylesheet" type="text/css" />
</head>
<body>
<form method="post" action="<?= $_SERVER["PHP_SELF"] ?>">
<!-- MANDATORY -->
<input name="search" type="text" value="test" />
<input name="dataType" type="hidden" value="HTML_SEGMENT" />
<!-- OPTIONAL -->
<input name="show" type="hidden" value="all" />
<input name="pageNumber" type="hidden" value="2" />
<input name="itemsPerPage" type="hidden" value="8" />
<input name="itemLinkTarget" type="hidden" value="_blank" />
<input type="submit" value="go" />
</form>
<?
$search = $_REQUEST["search"];
$dataType = $_REQUEST["dataType"];
$showAll = ($_REQUEST["show"] == "all");
$pageNumber = $_REQUEST["pageNumber"];
$itemsPerPage = $_REQUEST["itemsPerPage"];
$itemLinkTarget = $_REQUEST["itemLinkTarget"];
$out = "";
if(isset($_REQUEST["search"]) && $dataType == "HTML_SEGMENT"){
$search = urlencode($search);
// search uri with mandatory parameters
$searchUri = "http://www.sdaplus.com/search/web.aspx?search={$search}&dataType={$dataType}";
// add optional parameters if set
if($showAll)
$searchUri .= "&show=all";
if($pageNumber)
$searchUri .= "&pageNumber={$pageNumber}";
if($itemsPerPage)
$searchUri .= "&itemsPerPage={$itemsPerPage}";
if($itemLinkTarget)
$searchUri .= "&itemLinkTarget={$itemLinkTarget}";
$out = file_get_contents($searchUri);
}
?>
<!-- PLACE TO DISPLAY RESULTS -->
<div style="border: 1px solid; width: 800px;"><?= $out ?></div>
</body>
</html>
|
HTML Inclusion (Ajax/Proxy)If you want to embed search results to your page, you need to request the search and write the results to a desired location. However, in order to get the results, you need to place a particular Proxy file somewhere on your web server so you can access it. Also, place the javascript include directives in the head section of the page. Proxy is used to retrieve the search results from the search engine, and the javascripts files are used to post-process the page links of the result. proxy.aspx - to be used for the IIS web server - download
<%@ Language="C#" %>
<% /* proxy.aspx */
//##############################################################
// do not change the following code
//##############################################################
string searchUriBase = "http://www.sdaplus.com/search/";
// request parameters checking
if(!(Request["searchType"] != null && Request["search"] != null && Request["dataType"] != null))
throw new Exception("Invalid search request. Some mandatory parameter are missing.");
string searchType = Request["searchType"];
if(!(searchType == "web" || searchType == "yellowpages" || searchType == "products"))
throw new Exception("Invalid search type");
string dataType = Request["dataType"];
if(!(dataType == "HTML_PAGE" || dataType == "HTML_SEGMENT" || dataType == "XML"))
throw new Exception("Invalid data type");
// search URI
string searchUri = searchUriBase + searchType + ".aspx";
// processing parameters
string search = Request["search"];
bool showAll = Request["show"] == "all";
string pageNumber = Request["pageNumber"];
string itemsPerPage = Request["itemsPerPage"];
string cssUri = Request["cssUri"];
string showTopMenu = Request["showTopMenu"];
string showSearchForm = Request["showSearchForm"];
string itemLinkTarget = Request["itemLinkTarget"];
search = Server.UrlDecode(search);
System.Net.WebClient objRequest = new System.Net.WebClient();
objRequest.BaseAddress = searchUri;
// parameters collection
System.Collections.Specialized.NameValueCollection
objInf = new System.Collections.Specialized.NameValueCollection(30);
// mandatory parameters
objInf.Add("search", search);
objInf.Add("dataType", dataType);
// add optional parameters if set
if(showAll)
objInf.Add("show", "all");
if(pageNumber != null)
objInf.Add("pageNumber", pageNumber);
if(itemsPerPage != null)
objInf.Add("itemsPerPage", itemsPerPage);
if(cssUri != null)
objInf.Add("cssUri", cssUri);
if(showTopMenu != null)
objInf.Add("showTopMenu", showTopMenu);
if(showSearchForm != null)
objInf.Add("pageNumber", showSearchForm);
if(itemLinkTarget != null)
objInf.Add("itemLinkTarget", itemLinkTarget);
byte[] objRetBytes = objRequest.UploadValues(objRequest.BaseAddress, "POST", objInf);
Response.Write(Encoding.ASCII.GetString(objRetBytes));
%>
proxy.php - to be used for the PHP-enabled web server - download
<? /* proxy.php */
##############################################################
// do not change the following code
##############################################################
$searchUriBase = "http://www.sdaplus.com/search/";
// request parameters checking
if(!( isset($_REQUEST["searchType"]) && isset($_REQUEST["search"]) && isset($_REQUEST["dataType"])))
die("Invalid search request. Some mandatory parameter are missing.");
$searchType = $_REQUEST["searchType"];
if(!( $searchType == "web" || $searchType == "yellowpages" || $searchType == "products"))
die("Invalid search type");
$dataType = $_REQUEST["dataType"];
if(!( $dataType == "HTML_PAGE" || $dataType == "HTML_SEGMENT" || $dataType == "XML"))
die("Invalid data type");
// search URI
$searchUri = "{$searchUriBase}{$searchType}.aspx";
// processing parameters
$search = $_REQUEST["search"];
$showAll = ($_REQUEST["show"] == "all");
$pageNumber = $_REQUEST["pageNumber"];
$itemsPerPage = $_REQUEST["itemsPerPage"];
$cssUri = $_REQUEST["cssUri"];
$showTopMenu = $_REQUEST["showTopMenu"];
$showSearchForm = $_REQUEST["showSearchForm"];
$itemLinkTarget = $_REQUEST["itemLinkTarget"];
$search = urlencode($search);
// search uri with mandatory parameters
$searchUri .= "?search={$search}&dataType={$dataType}";
// add optional parameters if set
if($showAll)
$searchUri .= "&show=all";
if($pageNumber)
$searchUri .= "&pageNumber={$pageNumber}";
if($itemsPerPage)
$searchUri .= "&itemsPerPage={$itemsPerPage}";
if($cssUri)
$searchUri .= "&cssUri={$itemsPerPage}";
if($showTopMenu)
$searchUri .= "&showTopMenu=yes";
if($showSearchForm)
$searchUri .= "&showSearchForm=yes";
if($itemLinkTarget)
$searchUri .= "&itemLinkTarget={$itemLinkTarget}";
readfile($searchUri);
?>
* Note that you can write your own Proxy using your favorite programming language following the flow of our proxies. Javascript files should be used like this (in the HEAD section):
* It is important to set the proxy variable in your page to a path where the chosen Proxy resides. For example: <script type="text/javascript"> proxy = "proxy.aspx"; // for ASPX proxy proxy = "proxy.php"; // for PHP proxy </script> Proxy accepts the following mandatory parameters:
Additionally, Proxy accepts the following optional parameters:
Examples: for PHP Proxy, for ASPX Proxy |
XMLIf you want to get the search results in an XML format, you need to make the search request with both mandatory and optional parameters. Search requests have to be sent to an URI (e.g. http://www.sdaplus.com/search/web.aspx). There are some mandatory and optional parameters you need to include in the request. Mandatory parameters:
Optional parameters:
URIs for the full search request must look like the following (you may vary parameter list): http://www.sdaplus.com/search/web.aspx?search=hello&dataType=XML http://www.sdaplus.com/search/web.aspx?search=hello&dataType=XML&show=all http://www.sdaplus.com/search/web.aspx?search=hello&dataType=XML&show=all&showTopMenu=yes http://www.sdaplus.com/search/web.aspx?search=hello&dataType=XML&pageNumber=2&itemsPerPage=10 http://www.sdaplus.com/search/web.aspx?search=hello&dataType=XML&pageNumber=2&itemsPerPage=10&showTopMenu=yes |
