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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

node.js - Getting the socket id,user id pair of a logged in user(s) -

keyboard - C++ GetAsyncKeyState alternative -