Bonjour,


Je me heurte depuis deux jours à un problème que je ne parviens pas à résoudre, toute aide est donc plus que bienvenue.


Situation : l'entreprise pour laquelle je travaille dispose d'un site internet, développé par mes soins, accessible via une adresse du type http://www.mondomaine.fr. En parallèle, l'un des fournisseurs de l'entreprise a mis en place un service de consultation d'informations clients depuis Internet à l'adresse https://stat.mondomaine.fr. L'accès à ce service requiert une authentification via un formulaire en POST.

Problématique : je développe actuellement la version mobile du site internet à l'aide du framework jQuery Mobile, et je souhaiterai pouvoir y intégrer le service susmentionné. Cependant, bien que j'ai accès au serveur web du service, les fichiers .php sont encodés à l'aide d'ionCube, rendant toute modification directe impossible. J'ai donc eu l'idée de recourir à cURL afin d'importer le contenu dans mes propres pages.

Ma démarche a été la suivante :

  1. Utiliser Fiddler et décrypter le trafic HTTPS afin d'obtenir les paramètres et le header attendus par le serveur.
  2. Créer et exécuter la session cURL suivante :


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
42
 
$header = array(
	'Accept: text/html,application/xhtml+xml, application/xml;q=0.9,*/*;q=0.8',
	'Accept-Encoding: gzip, deflate',
	'Accept-Language: fr,fr-fr;q=0.8,en-us;q=0.5,en;q=0.3',
	'Connection: keep-alive'
);
 
$settings = array(
	'url'		=> 'https://stat.mondomaine.fr/php/authentification.php',
	'referer'	=> 'https://stat.mondomaine.fr',
	'agent'		=> 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:13.0) Gecko/20100101 Firefox/13.0.1',
	'fields'	=> 'id=' . urlencode('monid') . '&mdp=' . urlencode('monmdp') . '&md5=',
	'cookie'	=> __DIR__ . '/cookies.txt',
	'timeout'	=> 10
);
 
// CURLOPT_SSL_VERIFYHOST & CURLOPT_SSL_VERIFYPEER à false de façon temporaire
 
$curlopts = array(
	CURLOPT_URL		=> $settings['url'],
	CURLOPT_REFERER		=> $settings['referer'],
	CURLOPT_TIMEOUT		=> $settings['timeout'],
	CURLOPT_CONNECTTIMEOUT	=> $settings['timeout'],
	CURLOPT_USERAGENT	=> $settings['agent'],
	CURLOPT_HTTPHEADER	=> $header,
	CURLOPT_SSL_VERIFYHOST	=> false,
	CURLOPT_SSL_VERIFYPEER	=> false,
	CURLOPT_RETURNTRANSFER	=> true,
	CURLOPT_FOLLOWLOCATION	=> true,
	CURLOPT_COOKIESESSION	=> true,
	CURLOPT_COOKIEJAR	=> $settings['cookie'],
	CURLOPT_POST		=> true,
	CURLOPT_POSTFIELDS	=> $settings['fields']
);
 
$ch = curl_init();
 
curl_setopt_array($ch, $curlopts);
print curl_exec($ch); 
 
curl_close($ch);
Une fois authentifié, je suis bien redirigé vers https://stat.mondomaine.fr/php/affichage.php. Malheureusement, au lieu de récupérer les informations voulues, j'obtiens de multiples erreurs :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
Warning: pg_query(): supplied argument is not a valid PostgreSQL link resource in /chemin/php/fct_admin.php on line 33
 
Warning: pg_num_rows(): supplied argument is not a valid PostgreSQL result resource in /chemin/php/fct_admin.php on line 35
 
Warning: pg_query(): supplied argument is not a valid PostgreSQL link resource in /chemin/php/fct_admin.php on line 33
 
Warning: pg_num_rows(): supplied argument is not a valid PostgreSQL result resource in /chemin/php/fct_admin.php on line 35
 
Warning: pg_close(): supplied argument is not a valid PostgreSQL link resource in /chemin/php/fct_check.php on line 211
Sachant qu'en me connectant manuellement au site ou en forgeant la requête via l'application Postman pour Chrome, j'obtiens bien les informations voulues, je n'arrive pas à comprendre ce qui cause ces erreurs.


Merci par avance à qui prendra le temps d'examiner mon problème.