Login To InderWeb ! Just Play !

Username:
Password:

UserSubmittedComments

curl and ajax

Ajax request for google search results CURL

This code can be used to retrieve Google results for a keyword using ajax.

//This section will be excuted for ajax request and can be placed in seperate file
if(isset($_REQUEST['search']))
{
$ch = curl_init();
// set URL and other appropriate options
$result_cnt=10; //can be changed
$search=$_REQUEST['search']?$_REQUEST['search']:"";
$url="http://www.google.co.in/search?num=$result_cnt&hl=en&safe=off&q={$search}";

curl_setopt($ch, CURLOPT_URL, $url);

//Becoz we dont want to show result by default

Syndicate content