php curl for Google api not working but file_get_contents does -
i trying this
$url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&" . "q=paris%20hilton&userip=$_server[server_addr]"; // sendrequest // note how referer set manually $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_referer, 'http://google.com'); $body = curl_exec($ch); curl_close($ch); // now, process json string $json = json_decode($body); // have fun results...
that's pretty straight forward documents , not seem return file_get_contents same url not https http
i tried http curl no luck. appreciated guys :)
there small issue , notice generated that, should changed:
$url = "https://ajax.googleapis.com/ajax/services/search/web?v=1.0&" . "q=paris%20hilton&userip=" . $_server['server_addr'];
apart that, know have curl extension enabled? error?
Comments
Post a Comment