Archive for the 'CURL' Category

Remote Login with Curl PHP

The Curl Library of PHP can be used to open remote web pages and also logging in where a login is required.
Code

$login_url = ‘http://www.somesite.com/login.php’;
#These are the post data username and password
$post_data = ‘username=someusername&password=somepassword’;
#Create a curl object
$ch = curl_init();
#Set the useragent
$agent = $_SERVER["HTTP_USER_AGENT"];
curl_setopt($ch, CURLOPT_USERAGENT, $agent);
#Set the URL
curl_setopt($ch, CURLOPT_URL, $login_url );
#This is a POST query
curl_setopt($ch, CURLOPT_POST, 1 [...]