Friday, April 9, 2010

Retrieve data from other website

PHP made web development too easy..
PHP comes with a lot of file functions to read , write and perform various function from the hard drive, same if you want to find data from web not from hard drive or simply you can say that find data from third party then use cURL . Various hosting companies disable them for security reasons. Dont worry you can start cURL on your server by little change in php.ini file on your localhost server. Remove ';' sign from ';extension=php_curl.dll' in your php.ini file.
Well now you are ready to implement a killing application
cURL makes a HTTP request to retrieve information.

Hey I am giving here a very simple example to understand better

// We will load this url on our page
$url = 'http://www.google.co.in';
// now start cURL
$ch = curl_init();
// tell cURL about the URL
curl_setopt($ch, CURLOPT_URL, $url);
// tell cURL that you want the data back from that URL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// run cURL
$output = curl_exec($ch);
// end the cURL call (it will cleans up memory
curl_close($ch);
// display the output
echo $output;
?>

Check this little code on your local server or any web server.


Will back soon with new killing application..
Happy Coding..

No comments:

Post a Comment