Bonjour,

J'ai essayé avec ce code de poster dans un forum fluxbb :

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
43
44
45
46
47
48
49
50
51
<?php
//connexion via page de login 
$username="*******";
$password="********";
$url="http://forum.XXXXXX.XXX/";
$cookie="cookie.txt";
 
$postdata = "req_username=". $username ."&req_password=". $password ."&form_sent=1&redirect_url=".$url."index.php&login=S'identifier";
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url . "login.php?action=in");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
//curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_REFERER, $url . "index.php");
curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata);
curl_setopt ($ch, CURLOPT_POST, 1);
$result = curl_exec ($ch);
//fin de connexion, on ne ferme pas la curl en cours pour l'utiliser après
 
$sujet="Test subject";
$msg="test message ... test message ... test message ...";
 
$post = Array(
                'form_sent' => '1',
                'form_user' => $username,
                'req_subject' => $sujet,
                'req_message' => $msg,
                'hide_smilies' => '1',
                'subscribe' => '1',
                'submit' => 'Valider',
        );
 
//récupération du code source de la page dans un fichier texte pour traiter les informations via php
curl_setopt($ch, CURLOPT_URL, $url."post.php?action=post&fid=1");
curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6");
curl_setopt ($ch, CURLOPT_TIMEOUT, 60);
curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie);
curl_setopt ($ch, CURLOPT_POST, true);
curl_setopt ($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt ($ch, CURLOPT_REFERER, $url . "viewforum.php?id=1");
$ret = curl_exec($ch);
curl_close($ch);
echo $ret;
?>
L'identification est effectuée mais le post échoue à chaque fois. Quelques fois il me retourne juste la page de post et d'autres fois il me retourne : "Bad request. The link you followed is incorrect or outdated."