To be able to use this XML feed, you'll
need a script or program to transform the XML data into a HTML page. Here
is a sample PHP script that accomplishes this, which you may freely use and
adapt. Please note that the script is very rudimentary and will require some
customization.
http://www.entireweb.com/query?xml=1&pz=8e9a5c25b13f7e0938bc97f22f82fd60&q=QUERY&n=COUNT&of=OFFSET&a=ADULT&lang=LANGUAGE®ion=REGION&sc=SITECLUSTER
/****************************************************************************** ** ** ** YOU MUST REPLACE THE FOLLOWING WITH YOUR 32-DIGIT PZ IDENTIFICATION STRING ** ** *******************************************************************************/ $identification = "--- MY ID STRING ---"; /* Collect parameters to send to Entireweb */ $query = $_REQUEST['q']; $numresults = $_REQUEST['n'] ? $_REQUEST['n'] : 10; $offset = $_REQUEST['of'] ? $_REQUEST['of'] : 0; $adult = $_REQUEST['a'] ? $_REQUEST['a'] : 0; $language = $_REQUEST['lang'] ? $_REQUEST['lang'] : 'world'; $region = $_REQUEST['reg'] ? $_REQUEST['reg'] : 'world'; $sc = $_REQUEST['sc'] ? $_REQUEST['sc'] : 1; $ip = $_SERVER['REMOTE_ADDR']; /* This can be disabled for non-Premium partners */ /* Get response from Entireweb */ if (!($fp = fsockopen('www.entireweb.com', 80, $errno, $errstr, 60))) { die("Can't connect to Entireweb ($errno: $errstr)"); } fwrite($fp, "GET /query?xml=1&ip=$ip&pz=$identification&q=$query&n=$numresults&of=$offset&a=$adult&lang=$language®=$region HTTP/1.0\r\nHost: www.entireweb.com\r\nConnection: Close\r\nUser-Agent: Entireweb XML Feed Test Script\r\n\r\n"); $xml_data = ""; while (!feof($fp)) { $xml_data .= fgets($fp, 1024); } fclose($fp); /* Make sure we got a valid response, and skip ahead to after the HTTP header */ if (strncasecmp($xml_data, "HTTP/1.1 200 OK", strlen("HTTP/1.1 200 OK"))) { die("Invalid response from Entireweb!"); } $xml_data = str_replace("\r\n", "\n", $xml_data); $xml_data = strstr($xml_data, "\n\n"); $xml_data = str_replace("\n\n", "", $xml_data); /* Output page header */ echo "
";
/* Parse XML using expat */
$xml_parser = xml_parser_create();
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, true);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
if (!xml_parse($xml_parser, $xml_data, true)) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
/*** Functions to output result HTML page ***/
$ew_hit = array(); /* This variable will hold all data for the current hit */
/* writeHit: This function actually outputs the hit */
function writeHit() {
global $ew_hit;
echo $ew_hit['INDEX'] . ". " . $ew_hit['TITLE'] . "
" . $ew_hit['SNIPPET'] . "
" . $ew_hit['URL'] . '
';
}
/*** XML parsing functions ***/
$xml_tag = array();
/* startElement */
function startElement($parser, $name, $attrs) {
global $xml_tag;
global $ew_hit;
$xml_tag = $name;
if ($name == "HIT") { /* begin new hit */
$ew_hit = array();
$ew_hit['INDEX'] = $attrs['INDEX'];
}
}
/* endElement */
function endElement($parser, $name) {
global $ew_hit;
if ($name == "HIT")
writeHit();
}
/* characterData */
function characterData($parser, $data) {
global $xml_tag;
global $ew_hit;
$ew_hit[ $xml_tag ] .= str_replace("\n", "", $data);
}
echo "
";