Jeg mente nu den uden getPage (som virkede)... Nu kan jeg ikke teste længere, da jeg går ud fra du har ændret password?
Prøv:
<?php
define( "AGENT", "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-GB; rv:1.9.2) Gecko/20100115 Firefox/3.6 (.NET CLR 3.5.30729)" );
define( 'DIT_BRUGERNAVN', '' ); // fjernet
define( 'DIT_PASSWORD', '' ); // fjernet
$loginUrl = '
https://www.lectio.dk/lectio/285/login.aspx';// Første request
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $loginUrl );
curl_setopt( $ch, CURLOPT_COOKIESESSION, 1 );
curl_setopt( $ch, CURLOPT_HTTPGET, 1 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_USERAGENT, AGENT );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $ch, CURLOPT_COOKIEFILE, "cookie.txt" );
curl_setopt( $ch, CURLOPT_COOKIEJAR, "cookie.txt" );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_ENCODING , "gzip" );
$cnt = curl_exec( $ch );
curl_close( $ch );
// Find viewstate og eventvalidation
preg_match( "/__VIEWSTATE.*?value=\"(.*?)\"/i", $cnt, $m );
$viewstate = urlencode( $m[1] );
preg_match( "/__EVENTVALIDATION.*?value=\"(.*?)\"/i", $cnt, $m );
$eventval = urlencode( $m[1] );
// Byg POST
$post = '__EVENTTARGET=m%24Content%24submitbtn2'
.'&__EVENTARGUMENT='
.'&__VIEWSTATE=' . $viewstate
.'&__EVENTVALIDATION=' . $eventval
.'&m%24Content%24username2=' . DIT_BRUGERNAVN
.'&m%24Content%24password2=' . DIT_PASSWORD;
// LOGIN HER
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, $loginUrl );
curl_setopt( $ch, CURLOPT_REFERER, $loginUrl );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt ($ch, CURLOPT_POST, 1 );
curl_setopt( $ch, CURLOPT_POSTFIELDS, $post );
curl_setopt( $ch, CURLOPT_ENCODING , "gzip" );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array(
"Expect:"
,"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
,"Accept-Language: en"
,"Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7"
,"Keep-Alive: 115"
,"Connection: keep-alive"
) );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_USERAGENT, AGENT );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $ch, CURLOPT_COOKIEJAR, "cookie.txt" );
curl_setopt( $ch, CURLOPT_COOKIEFILE, "cookie.txt" );
$cnt = curl_exec( $ch );
curl_close( $ch );
header("Content-Type: text/plain");
echo "FØRSTE REQUEST GAV:\n\n$cnt\n\n----------------------\n\n";
// Hent skema
$ch = curl_init();
curl_setopt( $ch, CURLOPT_URL, "
https://www.lectio.dk/lectio/285/SkemaNy.aspx?type=elev&elevid=1628118635" );
curl_setopt( $ch, CURLOPT_REFERER, "
https://www.lectio.dk/lectio/285/forside.aspx" );
curl_setopt( $ch, CURLOPT_HTTPGET, 1 );
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $ch, CURLOPT_USERAGENT, AGENT );
curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, 1 );
curl_setopt( $ch, CURLOPT_COOKIEFILE, "cookie.txt" );
curl_setopt( $ch, CURLOPT_COOKIEJAR, "cookie.txt" );
curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, false );
curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
curl_setopt( $ch, CURLOPT_ENCODING , "gzip" );
$cnt = curl_exec( $ch );
curl_close( $ch );
echo "ANDET REQUEST: $cnt";