In this tutorial, I'll describe the some basics of using CURL and this is a very very beginner PHP CURL tutorial. Curl was developed by Daniel Stanberg and is used to communicate with other servers having different protocols.
Open php.ini file on your local server, search for 'curl'. You will find something like this ";extension=php_curl.dll". Remove ";" semi colon and restart your server. Now your Curl library will be activated.
<?php
$ch123 = curl_init("http://www.thetop100songs.com/");
$fo = fopen("example.txt", "w");
curl_setopt($ch123, CURLOPT_FILE, $fo);
curl_setopt($ch123, CURLOPT_HEADER, 0);
curl_exec($ch123);
curl_close($ch123);
fclose($fo);
?>
curl_init() function is use to start a session to any website on a server, for example, www.thetop100songs.com.
fopen() function will provide a write access to the file "example.txt".
curl_setopt() function sets the option to the session handle.
curl_exec() is used to execute a session to the site.
fclose() closes the file.
How to install Curl:
Open php.ini file on your local server, search for 'curl'. You will find something like this ";extension=php_curl.dll". Remove ";" semi colon and restart your server. Now your Curl library will be activated.
Basic Example:
<?php
$ch123 = curl_init("http://www.thetop100songs.com/");
$fo = fopen("example.txt", "w");
curl_setopt($ch123, CURLOPT_FILE, $fo);
curl_setopt($ch123, CURLOPT_HEADER, 0);
curl_exec($ch123);
curl_close($ch123);
fclose($fo);
?>
curl_init() function is use to start a session to any website on a server, for example, www.thetop100songs.com.
fopen() function will provide a write access to the file "example.txt".
curl_setopt() function sets the option to the session handle.
curl_exec() is used to execute a session to the site.
fclose() closes the file.
No comments:
Post a Comment