I have the following script for a bing search it receives a request from client and will return a formatted string via ajax... problem I have is using var for reference, can someone provide correct syntax? I want to replace the underlined "Web" with $type
Code:
<?php
$term="bodyguard";
$type="Web";
$count="10";
$ch = curl_init();
$timeout = 0; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, "http://api.bing.net/json.aspx?AppId=71D2A914321DB8A271270F748F0F5A3C4B4B4763&Market=en-US&Query=".$term."&Sources=".$type."&".$type.".Count=".$count."&JsonType=raw");
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$search = curl_exec($ch);
curl_close($ch);
$Response = json_decode($search,true);
foreach($Response[SearchResponse][Web][Results] as $item){
echo("
<div class='style4' style='margin-left:1em; margin-right:1em'>".$item[Title]."</div>
<div class='style6' style='margin-left:1em; margin-right:1em'>".$item[Description]."</div>
<div class='style4' style='margin-left:1em; margin-right:1em'><a href='".$item[Url]."' target='_blank'>".$item[Url]."</a></div>
<br>
");
}echo $Response;
?>
__________________
Sleeping Troll, EMUSE, Mind Expansion...Truly serendipity!
Last edited by Sleeping Troll; 07-26-2010 at 10:55 AM..
|