Code Snippet
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
'>http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
; <title>Live Search API 2.0 through PHP</title>
</head>
<body>
<?php
$APPID = "Your AppID here";
?>
<form method="post" action="<?php echo $PHP_SELF;?>">
<input type="text" id="searchBox" name="searchBox" value="<?php
if (isset($_POST['searchBox'])){
echo($_POST['searchBox']);
}
else {
echo('Microsoft');
}
?>"/>
<input type="submit" value="Search" name="submit" id="searchButton" />
<?php
if (isset($_POST['submit']))
{
$request = 'http://api.search.live.net/json.aspx?Appid=' . $APPID . '&sources=web&query=' . urlencode( $_POST["searchBox"]);
$response = file_get_contents($request);
$jsonobj = json_decode($response);
echo('<ul ID="resultList">');
foreach($jsonobj->SearchResponse->Web->Results as $value)
{
echo('<li class="resultlistitem"><a href="' . $value->Url . '">');
echo('<h3>' . $value->Title . '</h3></a>');
echo('<p>' . $value->Description . '</p>');
}
echo("</ul>");
}
?>
</form>
</body>
</html>