<?php
header
("Content-type: text/html; charset=UTF-8");

error_reporting(0);
#####################################################
# BUILDASEARCH PALM APP CATALOG SEARCH API
 # USING SIMPLEXML V.011309 
# ALTERNATIVELY YOU CAN USE DOM INSTEAD OF SIMPLEXML
#####################################################
$SECRET 'palm';//NAME MAY NEED TO BE ENCRYPTED IN FUTURE API RELEASES
$QUERY urlencode($_GET['e']);
$START 0;
$NUM 10;

if(empty(
$QUERY)){

#echo 'you can\'t get nothing with nothing.';
echo '<form method="get" action="">';
echo 
'<input type="text" name="e">';
echo 
'<input type="submit" value="search">';
echo 
'</form>';
 
 } else {    

//BUILDASEARCH API URL
$API 'http://bas.buildasearch.com/xml/'.$SECRET.'?e='.$QUERY.'&bastart='.$START.'&bascount='.$NUM.'';


//LOAD EXTERNAL BAS API
$xml simplexml_load_file($API'SimpleXMLElement',LIBXML_NOCDATA);

//DISPLAY TOTAL
$result $xml->xpath('/response/results/bastotal');
while(list( , 
$node) = each($result)) {
    echo 
'total: ',$node,"<br/>";
}


//EXPLODE DOMAIN FOR IMAGE

//DISPLAY RECORDS BELOW
foreach ($xml->results->basresult as $record) {
    
$summary $record->basummary;    
echo 
'<a href="'.$record->longurl.'">'.utf8_decode($record->title).'</a><br/>';
echo 
$summary.'</br>';
echo 
$record->showurl.'</br>';
echo 
'<hr/>';
        }
}
?>