Lees mijn webbrowser tutorial :)
Link gekopieerd
Ah daar kom ik al een stukje verder mee!
Echter heb ik nog 1 probleem. Hij geeft als error dat me gebruikersnaam of wachtwoord onjuist is.
ik heb nu de volgende code:
<?php
// Nodige informatie
define('SERVER', 'www.knvb.nl');
define('PORT', 80);
define('PATH', '/mijn?cc_req=1;next=%2Fclubs_comp%2Fteam_standen%3Fclub_id%3DBBBD193%26team_id%3D91305%26comp_id%3DNO-0212**-11-60966*!');
// Versie
define('VERSION', '1.0');
// End of line
define('_EOL', "\r\n");
// Data
$password = md5("***");
$data = array('email' => '[email protected] ', 'password' => '***');
// Maak een socket
$sock = socket_create(AF_INET, SOCK_STREAM, 0);
if (!$sock) {
echo 'Fatal error: Couldn\'t create socket';
exit;
}
// Maak verbinding
if (!socket_connect($sock, SERVER, PORT)) {
echo 'Fatal error: Couldn\'t connect';
exit;
}
// Maak het body stuk
$body = null;
foreach ($data as $var => $content) {
if ($body != null) {
$body .= '&';
}
$body .= rawurlencode($var) . '=' . $content;
}
//echo $body;
// Maak het request
$request = null;
$request .= 'POST ' . PATH . ' HTTP/1.0' . _EOL;
$request .= 'Host: ' . SERVER . _EOL;
$request .= 'User-Agent: LegolasWeb WebBrowserDemo ' . VERSION . _EOL;
$request .= 'Content-Type: application/x-www-form-urlencoded' . _EOL;
$request .= 'Content-Length: ' . strlen($body) . _EOL;
$request .= _EOL;
$request .= $body;
//echo $request;
// En verstuur het
if (!socket_send($sock, $request, strlen($request), 0)) {
echo 'Fatal error: Couldn\'t send request';
exit;
}
// Haal de response op
$output = null;
$buffer = null;
while (socket_recv($sock, $buffer, 1024, 0) != 0) {
$output .= $buffer;
}
// Isoleer het body gedeelte en toon het
//$output = explode(_EOL . _EOL, $output);
//$output = $output[1];
echo $output;
?>
Link gekopieerd
oke ik word nu ingelogd. ik krijg alleen de volgende header terug:
HTTP/1.0 302 Moved Temporarily
Date: Sat, 07 Oct 2006 09:11:49 GMT
Server: Apache/1.3.33 (Unix) mod_perl/1.29
Set-Cookie: sessionId=464574e22df71cb20a1c29a4349952b7; path=/; expires=Tue, 04-Oct-2016 09:11:49 GMT
Location: /clubs_comp/team_standen?club_id=BBBD193&team_id=91305&comp_id=NO-0212**-11-60966*!
Content-Type: text/plain
X-Cache: MISS from knvbsq02
Connection: close
HTTP/1.1 302 Found
Date: Sat, 07 Oct 2006 09:11:49 GMT
Server: Apache/1.3.33 (Unix) mod_perl/1.29
Set-Cookie: sessionId=464574e22df71cb20a1c29a4349952b7; path=/; expires=Tue, 04-Oct-2016 09:11:49 GMT
Set-Cookie: sessionId=464574e22df71cb20a1c29a4349952b7; path=/; expires=Tue, 04-Oct-2016 09:11:49 GMT
Location: /clubs_comp/team_standen?club_id=BBBD193&team_id=91305&comp_id=NO-0212**-11-60966*!
Connection: close
Content-Type: text/html; charset=ISO-8859-1
Pragma: no-cache
hoe zorg ik er nou voor dat ik nu alsnog ingelogd en al de pagina:
http://www.knvb.nl/clubs_comp/team_standen?club_id=BBBD193&team_id=91305&comp_id=NO-0212**-11-60966* ! in een variabele krijg?
Link gekopieerd