Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 96 lines (91 sloc) 3.234 kB
24ee77c @codepo8 fixes
authored
1 <?php
f3517de @codepo8 added disclaimer
authored
2 /*
3 GooHooBi API by Christian Heilmann
4 Homepage: http://github.com/codepo8/GooHooBi
5 Copyright (c)2009,2010 Christian Heilmann
6 Code licensed under the BSD License:
7 http://wait-till-i.com/license.txt
8 */
24ee77c @codepo8 fixes
authored
9 ?>
0e5c532 @codepo8 php version
authored
10 <?php if(isset($_GET['json'])){
11 header('content-type:text/javascript');
12 echo 'goohoobi.se({"result":"';
13 }?>
14 <?php if(isset($_GET['search'])){
15 $query = filter_input(INPUT_GET, 'search', FILTER_SANITIZE_SPECIAL_CHARS);
24ee77c @codepo8 fixes
authored
16
17 $queries[] = 'select Title,Description,Url,DisplayUrl '.
18 'from microsoft.bing.web(20) where query="'.$query.'"';
19 $queries[] = 'select title,clickurl,abstract,dispurl '.
20 'from search.web(20) where query = "'.$query.'"';
21 $queries[] = 'select titleNoFormatting,url,content,visibleUrl '.
22 'from google.search(20) where q="'.$query.'"';
23 $url = "select * from query.multi where queries='".join($queries,';')."'";
24 $api = 'http://query.yahooapis.com/v1/public/yql?q='.
25 urlencode($url).'&format=json&env=store'.
26 '%3A%2F%2Fdatatables.org%2Falltableswithkeys&diagnostics=false';
27
0e5c532 @codepo8 php version
authored
28 $ch = curl_init();
29 curl_setopt($ch, CURLOPT_URL, $api);
30 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
31 $output = curl_exec($ch);
32 curl_close($ch);
33 $data = json_decode($output);
34 if($data->query){
35 if($data->query->results->results[0]){
36 $res = $data->query->results->results[0]->WebResult;
37 $bing = '<h2>Bing</h2><ul>';
38 $all = sizeof($res);
39 for($i=0;$i<$all;$i++){
40 $bing .= '<li><h3><a href="'.$res[$i]->Url.'">'.$res[$i]->Title.
41 '</a></h3><p>'.$res[$i]->Description.'<span>('.
42 $res[$i]->DisplayUrl.')</span></p></li>';
43 }
44 $bing .= '</ul>';
45 } else {
46 $bing = '<h2>Bing</h2><h3>No results found.</h3>';
47 }
48 if($data->query->results->results[1]){
49 $res = $data->query->results->results[1]->result;
50 $yahoo = '<h2>Yahoo</h2><ul>';
51 $all = sizeof($res);
52 for($i=0;$i<$all;$i++){
53 $yahoo .= '<li><h3><a href="'.$res[$i]->clickurl.'">'.$res[$i]->title.
54 '</a></h3><p>'.$res[$i]->abstract.'<span>('.
55 $res[$i]->dispurl.')</span></p></li>';
56 }
57 $yahoo .= '</ul>';
58 } else {
59 $yahoo = '<h2>Yahoo</h2><h3>No results found.</h3>';
60 }
61 if($data->query->results->results[2]){
62 $res = $data->query->results->results[2]->results;
63 $google = '<h2>Google</h2><ul>';
64 $all = sizeof($res);
65 for($i=0;$i<$all;$i++){
66 $google .= '<li><h3><a href="'.$res[$i]->url.'">'.
67 $res[$i]->titleNoFormatting.
68 '</a></h3><p>'.$res[$i]->content.'<span>('.
69 $res[$i]->visibleUrl.')</span></p></li>';
70 }
71 $google .= '</ul>';
72 } else {
73 $google = '<h2>Yahoo</h2><h3>No results found.</h3>';
74 }
75
76
77 $out = '<div class="yui-gb">'.
78 '<div class="yui-u first" id="google">'.$google.'</div>'.
79 '<div class="yui-u" id="yahoo">'.$yahoo.'</div>'.
80 '<div class="yui-u" id="bing">'.$bing.'</div>'.
81 '</div>';
82 } else {
83 $out = '<h3>Error retrieving data.</h3>';
84 }
85 ?>
86 <?php }?>
f9fe719 @codepo8 php version
authored
87 <?php if(isset($_GET['research'])){
88 $out = preg_replace("/<a /",'<a target="fr" ',$out);
89 }?>
0e5c532 @codepo8 php version
authored
90 <?php if(isset($_GET['json'])){
91 echo addslashes($out);
92 echo '"})';
93 } else {
94 echo $out;
95 }?>
Something went wrong with that request. Please try again.