Bonjour !

Je travaille actuellement sur le site d'une médiathèque. Ils utilisent un SGBD proprio codé en ASP (argh) pour la gestion de leur bibliothèque...
Du coup pour intégrer les éléments dans un site "externe", il faut passer par une iframe ce qui est pas franchement propre.
J'ai donc opté pour la solution CURL, afin de traiter les différents formulaires (recherche, login...) mais j'ai apparemment un soucis...
Voici la page à traiter :
http://www.mediatheque-agglo-sgms.fr...aspx?IdPage=49

Et voici mon code
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
	<?php
	// Le texte recherché 
	$search = "test";
 
	// Url de la page à traiter
	$url = "http://www.mediatheque-agglo-sgms.fr/opacwebaloes/index.aspx?IdPage=49";
 
	// Récupération du __viewstate
	$recupviewstate = file_get_contents($url);
	preg_match_all("/name=\"__VIEWSTATE\" value=\"(.*?)\"/", $recupviewstate, $arr_viewstate);
	$viewstate = $arr_viewstate[1][0];
 
	$postfields = array();
	$postfields["__VIEWSTATE"] = $viewstate;
	$postfields["_ctl0:_ctl3:_ctl0:Critere_82_406_num:txtSaisie1"] = urlencode($search);
 
	$useragent = "Mozilla/5.0";
	$referer = $url; 
 
	// Initialisation d'une session cURL
	$ch = curl_init($url);
 
	// Options cURL
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
	curl_setopt($ch, CURLOPT_USERAGENT, $useragent);
	curl_setopt($ch, CURLOPT_REFERER, $referer);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
 
	// ASP.NET_SessionId
	curl_setopt($ch, CURLOPT_COOKIEJAR, dirname(__FILE__).'/cookie.txt');	
	curl_setopt($ch, CURLOPT_COOKIEFILE, dirname(__FILE__).'/cookie.txt');
 
	// Execution
	$result = curl_exec($ch);
	curl_close($ch);
 
	// Affichage
	echo $result;
	?>
Cependant rien à faire, CURL me retourne le formulaire non traité...
Quelqu'un à peut-être une idée ?

Merci !

PS : J'ai bien Chmod 777 le fichier cookie.txt !