Created
March 10, 2015 12:32
-
-
Save ridho1991/e3e922cea09d838524db to your computer and use it in GitHub Desktop.
Google Keyword Suggest
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function google_suggest($query) { | |
$xml = simplexml_load_file ( utf8_encode ( "http://www.google.com/complete/search?output=toolbar&hl=en&q=" . $query . "" ) ); | |
$suggest=array(); | |
if (@$xml) { | |
foreach ( $xml->children () as $child ) { | |
foreach ( $child->suggestion->attributes () as $data ) { | |
$suggest [] = $data; | |
} | |
} | |
return $suggest; | |
} | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Google 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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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']; | |
$google_key=google_suggest($q); | |
foreach($google_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