There is this website https://www.bricklink.com/catalogDownload.asp which should download a .xml or .txt file automatically if the link is called. The only problem is, that it seems like you must be logged in to call that link. My goal is to write a piece of code which automatically fills the login form and afterwards calls the link again to download the file. My two main problems are to get how to fill the two login parameters and how to make sure I am still logged in afterwards in order to be able to download the file.
My first approach looks like this:
$postdata = http_build_query(
array(
'frmUsername' => 'myUsername',
'frmPassword' => 'myPassword'
)
);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents('https://bricklink.com/catalogdownload.asp', false, $context);
print_r($result);
Firstly, I am creating the httpRequest-body and secondly, I am calling the url mentioned above.