Skip to content

Instantly share code, notes, and snippets.

@ridho1991
Created March 13, 2015 03:00
Show Gist options
  • Save ridho1991/772754dc14e618be66f9 to your computer and use it in GitHub Desktop.
Save ridho1991/772754dc14e618be66f9 to your computer and use it in GitHub Desktop.
Bing Keyword Suggest
<?php
function bing_suggest($query) {
$geturl = file_get_contents ( utf8_encode ( "http://api.bing.com/osjson.aspx?query=" . $query . "" ) );
$keywords = json_decode ( $geturl, 1 );
$suggest=array();
if(isset($keywords[0])) {
$z = 1;
foreach($keywords[1] as $keys) {
$suggest [] = $keys;
$z++;
}
}
return $suggest;
}
?>
<html>
<head>
<meta charset="UTF-8">
<title>Bing Keyword Suggest</title>
</head>
<body>
<form action="keyword.php" method="get">
<input type="text" id="q" name="q" value="" placeholder="Enter text here"/>
<button type="submit" value="" >Submit</button>
</form>
</body>
</html>
<html>
<head>
<title><?php echo $_GET['q'];;?></title>
<meta charset="UTF-8">
</head>
<body>
<?php
ini_set('max_execution_time', 0);
ini_set('memory_limit', '999M');
require_once('api.php');
$q=$_GET['q'];
$bing_key=bing_suggest($q);
foreach($bing_key as $key){
echo $key.'<br>';
}
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment