Mateusz Kudej
Mateusz Kudej

Reputation: 497

Logging into a server with cURL

I need to write parser. And I must login there: http://24travels.pl/web/export.pl?o=10004&co=imprezy

But this is not POST form. This is a .htaccess server lock. Anyone have idea to login there Using a curl or something?

I need to do auto parser from this site, but first I must login there.

Upvotes: 0

Views: 141

Answers (1)

you can use CURLOPT_USERPWD to achieve this.

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://24travels.pl/web/export.pl?o=10004&co=imprezy');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt(CURLOPT_USERPWD, '[username]:[password]')

$data = curl_exec();
curl_close($ch);
 ?> 

Upvotes: 1

Related Questions