| | |
Google Search API???
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
Hi and I have been looking around and found that google has a few search api's but haven't yet found one that returns the results as a javascript/ajax array. Is it possible to at least get the google api to send the results to my website as a variable/array in javascript/ajax/php because can't see any reference to this.
PS. This is in the php section because all results will eventually end up in php. Also I tried the file_get_contents() function and curl on the google homepage but google knows it's a bot.
PS. This is in the php section because all results will eventually end up in php. Also I tried the file_get_contents() function and curl on the google homepage but google knows it's a bot.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
According to the section "PHP Access" in http://code.google.com/apis/ajaxsear...on/#The_Basics it should be possible.
My guess is you already tried this. At work we use the paid version of google search, which just returns xml.
My guess is you already tried this. At work we use the paid version of google search, which just returns xml.
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
From all the pages I clicked I didn't find that section. But does anybody know how to return 10 results instead of 4 ?
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
http://code.google.com/apis/ajaxsear..._class_GSearch
See the "Searchers" section. Appears to be limited to 4 or 8.
See the "Searchers" section. Appears to be limited to 4 or 8.
"If it is NOT source, it is NOT software."
-- NASA
-- NASA
Any idea on how to implement that into the php script on the first link? I can't see how it fit's in but am trying to work it out.
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
I have solved it and will post some code soon.
Edit:
Here is the code which solved my problem:
Edit:
Here is the code which solved my problem:
php Syntax (Toggle Plain Text)
$searchterm='Paris Hilton'; $searchterm=urlencode($searchterm); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q='.$searchterm.'&start=0'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_REFERER, 'http://www.syntax.cwarn23.info/'); $body = curl_exec($ch); curl_close($ch); $string = json_decode($body); $dstring=''; foreach ($string->responseData->results AS $val) { $dstring.='<<---<<>-><'; $dstring.=str_replace(array('<<---<<>-><','<b>','</b>','<em>','</em>','<i>','</i>'),'',$val->title); $dstring.='<<---<<>-><'; $dstring.=str_replace('<<---<<>-><','',$val->url); } $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q='.$searchterm.'&start=4'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_REFERER, 'http://www.syntax.cwarn23.info/'); $bodyb = curl_exec($ch); curl_close($ch); $stringb = json_decode($bodyb); foreach ($stringb->responseData->results AS $valb) { $dstring.='<<---<<>-><'; $dstring.=str_replace(array('<<---<<>-><','<b>','</b>','<em>','</em>','<i>','</i>'),'',$valb->title); $dstring.='<<---<<>-><'; $dstring.=str_replace('<<---<<>-><','',$valb->url); } $dstring=substr($dstring,11); //echo '<br>'.$dstring; $array=explode ('<<---<<>-><',$dstring); echo '<xmp>'; print_r($array); echo '</xmp>';
Last edited by cwarn23; Sep 15th, 2009 at 10:13 am. Reason: added code
Try not to bump 10 year old threads as it can be really annoying.
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
Like php then read my website at http://syntax.cwarn23.net/
Star-Trek-Atlantis - now that's what I call a movie ^_^
My favourite PC. - MacGyver Fan
Bad english note: dis-iz-2b4u
![]() |
Similar Threads
- How to put google search in your site (Site Layout and Usability)
- More than 100 google results with google API? (Python)
- News Story: Google's Mayer Predicts Personalization Is Key to Future Search (Search Engine Optimization)
- google ajax search api ( youtube videoBar) (JavaScript / DHTML / AJAX)
- News Story: Google Launches Enhanced Enterprise Hosted Search Product (Search Engine Optimization)
- Random Google Search (PHP)
- Google Search (Pay-Per-Click Advertising)
Other Threads in the PHP Forum
- Previous Thread: why using double quotes..
- Next Thread: I need a little tweek to a page nav code
| Thread Tools | Search this Thread |
adsense advertising aim ajax analytics android aol api apple array asp bing blackberry blogging browser business cellphone chrome cloudcomputing code database developer development doubleclick earnings email engine europe facebook firefox flash form forms g1 gmail google googledocs googleearth government hp html ibm include internet iphone java javascript jquery link linux login malware maps marketing mcafee microsoft mobile monetization msdn myspace mysql netbooks news office opensource pagerank php privacy programming publishing query revenue rss search searchengine security seo sex socialnetwork socialnetworking software spam spyware sql statistics t-mobile twitter upload verizon video vista voice voip web website windows wolframalpha yahoo yahoo! youtube







