Heey allemaal

Ik ben bezig een pagina uit te lezen. Het gaat op een pagina met rooster informatie.
Hiervoor moet je eerst inloggen. Dit inloggen wil ik versturen via post. Dus: Post versturen naar een externe php pagina. Ik gebruik hiervoor curl. Dit werkt opzich prima. Alleen zit ik met een probleem. Bij het verzenden naar de pagina krijg ik een 302 error. Object moved... Het volgende van de redirect lukt niet. Heeft iemand ervaring met Curl?

Groet Jan Veenstra

[size=xsmall]Toevoeging op 17/11/2010 12:56:18:[/size]

Bij deze mijn code

  $ch = curl_init();  
  curl_setopt($ch, CURLOPT_URL, "https://orkp.avans.nl/login.asp");  
  curl_setopt($ch, CURLOPT_POST, 1); 
  curl_setopt($ch, CURLOPT_POSTFIELDS, "txtUserName=***&txtPassword=***&cmdLogin=Login");    
  $result = curl_exec( $ch ); // runs the post 
  curl_close($ch); 
  echo "Reply Response: " . $result; // echo reply response 
Ik gebruik normaal het volgende, Het werkt wel helaas niet voor alle websites.

Ik gok dat je het allow redirection gedeelte nodig hebt.

<?php

/*--------------------------------------------------------------------------------------------------------------------------
(§) Settings | Login.
--------------------------------------------------------------------------------------------------------------------------*/

#| Username.

$username = '';


#| Login password.

$password = '';


#| Url.

$login_url = '';


/*--------------------------------------------------------------------------------------------------------------------------
(§) cURL | Initialize cURL session.
--------------------------------------------------------------------------------------------------------------------------*/

#| Initialize cURL session

$cURL = curl_init();


/*--------------------------------------------------------------------------------------------------------------------------
(§) cURL | Default cURL settings.
--------------------------------------------------------------------------------------------------------------------------*/

#| Set cURL to return data.

curl_setopt ($cURL, CURLOPT_RETURNTRANSFER, 1);


/*--------------------------------------------------------------------------------------------------------------------------
(§) cURL | Login.
--------------------------------------------------------------------------------------------------------------------------*/

#| Allow redirection.

curl_setopt($cURL, CURLOPT_FOLLOWLOCATION, 1);


#| Set COOKIE.

curl_setopt($cURL, CURLOPT_COOKIEJAR, 'cookie.txt');


#| Set login url.

curl_setopt($cURL, CURLOPT_URL, $login_url);


#| Set it to post data

curl_setopt($cURL, CURLOPT_POST, 1);


#| Set POST data.

curl_setopt($cURL, CURLOPT_POSTFIELDS, 'username='.$username.'&password='.$password);


#| Execute login.

$result = curl_exec($cURL);


/*--------------------------------------------------------------------------------------------------------------------------
(§) cURL | Close cURL session.
--------------------------------------------------------------------------------------------------------------------------*/

#| Close cURL session.

curl_close($cURL);

?>
Object Moved
This object may be found here.

Helaas, nog niet gelukt...
Iemand nog ideeën?

Het gaat overigens om orkp.avans.nl
Hoe ziet je code er op het moment uit?

Reageren