Précédent   Forum des professionnels en informatique > PHP > Bibliothèques et frameworks
Bibliothèques et frameworks Forum d'entraide sur les frameworks, templates, bibliothèques de code (PDFLib, eZPdf, JpGraph, Artichow, PEAR, etc). Avant de poster : FAQ bibliothèques, toutes les FAQ PHP et cours bibliothèques
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 10/07/2011, 13h38   #1
Invité régulier
 
Inscription : mai 2006
Messages : 35
Détails du profil
Informations forums :
Inscription : mai 2006
Messages : 35
Points : 5
Points : 5
Par défaut cURL poster dans un forum fluxbb

Bonjour,

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

Code :
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."
BMABMA est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 23h37.


 
 
 
 
Partenaires

Hébergement Web