Click here



tyde
2006-11-07 16:57:41
results useful useful01 02 31 using would

After looking around for a class that would extract keywords from the Overture Keyword Inventory database, I decided it was just as well to do up my own class.

You can use this to look up keywords and view the results. Hope you find it useful.


01
02 <?
03     class OvertureSuggest {
04         private $BaseWords;
05         /** constructor */
06         function __construct($BaseWords) {
07             $this->BaseWords $BaseWords;
08         }
09         function getSuggestions() {
10             $query 'http://inventory.overture.com/d/searchinventory/suggestion/';
11             $query .= '?term='.urlencode($this->mBaseWords).'&mkt=us&lang=en_US';
12             $data file_get_contents($query);
13             $data strip_tags($data);
14             $pattern "/ ([0-9]+)n (.+)/i";
15             preg_match_all($pattern,$data,$Matches);
16             
17             $Cnts $Matches[1];
18             $Words = array();
19             for ($i=0;$i<count($Matches[2]);$i++) {
20                 $Words[$Matches[2][$i]] = intval($Cnts[$i]);
21             }
22             return $Words;
23         }
24     }
25     
26     // Sample Usage:
27     $suggest = new OvertureSuggest('Affiliate');
28     echo "<pre>".print_r ($suggest->getSuggestions(),true)."</pre>";
29     exit;    
30 ?>
31

Posted in PHP
CAPTCHA