Hi all,
I’ve found some code that reads out some text when submitted (I adjusted it slightly so it does it on the fly rather than going to another site), how can I combine this with Bing’s search API?
Here’s the text to speech code:
<form method="post" action="http://vozme.com/text2voice.php" target="hiddeniframe">
<textarea id="text" cols="40" rows="1" name="text">
Enter Text
</textarea><br>
<button style="background-color:white;
background-image:
url(http://vozme.com/img/megaphone40x40w.gif);
background-position: top center;
background-repeat:no-repeat;
height: 48px; font-size:70%;
padding:4px 4px 4px 44px;">
</button>
</form>
<iframe height="1" width="1" name="hiddeniframe" style="display: none;"></iframe>
Here’s the Bing API:
<html>
<head>
<link href="styles.css" rel="stylesheet" type="text/css" />
<title>PHP Bing</title>
</head>
<body>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
Enter Search:<input type="text" id="searchText" name="searchText" value="<?php
if (isset($_POST['searchText'])){
echo($_POST['searchText']); }
else {
echo('');
} ?>"/>
<input type="submit" value="Search!" name="submit" id="searchButton" />
<?php
if (isset($_POST['submit'])) {
$request =
'http://api.bing.net/json.aspx?Appid=8CFD0925A6B1745AFE2F0F359DCD8D4D9DD6A5CE&sources=web&Web.Count=5&query=' . urlencode( $_POST["searchText"]);$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 . '">'. $value->Title .'</a>');
echo('<p>'. $value->Description .'</p>');
echo('</li>');
}
echo("</ul>");
}
?>
</form>
</body>
</html>
What I want to happen is when you click a submit it reads out the text in the box and shows the Bing results as normal.
Cheers