IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Curl php Post data : projet autobook appoitment


Sujet :

Langage PHP

  1. #1
    Membre régulier
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2018
    Messages
    89
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2018
    Messages : 89
    Points : 85
    Points
    85
    Par défaut Curl php Post data : projet autobook appoitment
    Bonjour a tous ,

    dans ma derniere j'ai fais résolus pck j'ai fais une erreur bete .

    voila donc autre fois je n 'arrive pas a faire un post data ,dans la derniere partie du code .

    j ai réussis a avoir les parametres a poster , voir dans le 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
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    	<?php
     
    		set_time_limit(0);// to infinity for 
     
     
    		$ch = curl_init();
            $url1 = 'https://fr.example.com/tn/TUN/login.php';
    		$url2 = 'https://fr.example.com/tn/TUN/action.php';
     
    		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    		curl_setopt($ch, CURLOPT_URL, $url1);
    		curl_setopt($ch, CURLOPT_COOKIEFILE, 'C:\AppServ\www\curl\cookie.txt');
    		curl_setopt($ch, CURLOPT_COOKIEJAR, 'C:\AppServ\www\curl\cookie.txt');
    		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
     
     
    		$co = curl_exec($ch);
     
     
    	$doc = new DOMDocument();
    	libxml_use_internal_errors(true);
    	$doc->loadHTML($co);
    	# Parse the HTML
    	# The @ before the method call suppresses any warnings that
    	# loadHTML might throw because of invalid HTML in the page.
    	$xpath = new DOMXPath($doc);
     
    	$val1 = $xpath->query('//input[@name="_sid"]/@value')->item(0)->nodeValue;
     
     
    	echo $val1; 
     
     
     
    	 echo '<br/>';
     
    		 $field['process'] = 'login';
    		$field['_sid'] = $val1;
    		$field['email'] = 'myemail@example.com';
    		$field['pwd'] = '123456';
     
    		$datafield = http_build_query($field);
    		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    		curl_setopt($ch, CURLOPT_COOKIEFILE, 'C:\AppServ\www\curl\cookie.txt');
    		curl_setopt($ch, CURLOPT_COOKIEJAR, 'C:\AppServ\www\curl\cookie.txt');
    		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    		curl_setopt($ch, CURLOPT_POST, true);
    		curl_setopt($ch, CURLOPT_POSTFIELDS, $datafield);
    		curl_setopt($ch, CURLOPT_VERBOSE, true);
     
    		curl_exec($ch);
     
    		curl_setopt($ch, CURLOPT_URL, 'https://fr.example.com/tn/TUN/myapp.php?fg_id=5622739');
     
    		$cur = curl_exec($ch);
     
     
     
    	$do = new DOMDocument();   // New  dom Doc to Get URL from  disponible dates
    	libxml_use_internal_errors(true);
    	$do->loadHTML($cur);
    	# Parse the HTML
    	# The @ before the method call suppresses any warnings that
    	# loadHTML might throw because of invalid HTML in the page.
    	$xpath = new DOMXPath($do);
    	$onClickAttrNodeList = $xpath->query('//a[@class="dispo"]/@onclick'); //array contains URL 
    	preg_match('#var secret_id = (.*)\;#Us', $cur, $out);  // Pregmatch  Secret ID from javascript  CODE 
    	$secret_id = json_decode($out[1]);  // Get secret ID
     
     
    	$array = array();         // CONVERT NODE LIST  OBJECT TO ARRAY
    	foreach($onClickAttrNodeList as $node){
    		$array[] = $node;
    	}
     
     
    	$x=array();
    	   foreach($array as $node) {
    		   for($i = 0; $i < 20; ++$i) {
    		 $x[] = $node->nodeValue;  //PARSE ALL LINK AS TABLE
    	}
     
    	}
    	$randlink = array_rand($x, 20);   //get gandom link
    	$link = $x[$randlink[0]];
     
    	echo '<br/>';
    	echo '<br/>';
    	echo $secret_id;
    	echo '<br/>';
    	echo '<br/>';
     
    	echo '<br/>';
    	preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $link, $match);  //Get URL from the last array
    	   echo "<pre>";
    	   $url = $match[0];
    	print_r($url[0]); 
     
    	echo'<br/>';
     
    	parse_str( parse_url( $url[0], PHP_URL_QUERY), $arrayurl );   // avoir les parametres pour  poster 
     
     
    	var_dump($arrayurl);
    	echo'<br/>';
    	echo'<br/>';
    	echo $arrayurl[fg_id];
    	echo $arrayurl[fg_id];
    	echo'<br/>';
     
    		echo'<br/>';  
    // dans cette partie du code je n arrive pas a faire le POST 
    		$fieldbook['f_id'] = '';
    	    $fieldbook['fg_id'] = $arrayurl[fg_id];
    		$fieldbook['what'] = $arrayurl[what];
    		$fieldbook['result'] = $arrayurl[result];
    		$fieldbook['as_u_id'] = '';
    		$fieldbook['_sid'] = $secret_id;
    		$fieldbook['timestamp'] = $arrayurl[timestamp];
    		$fieldbook['skey'] = $arrayurl[skey];
    		$fieldbook['process'] = $arrayurl[process];
    		$fieldbook['reloader_timestamp'] = '1540935836428';
     
     
    		$bookrdv = http_build_query($fieldbook);
    		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    		curl_setopt($ch, CURLOPT_URL, $url2);
    		curl_setopt($ch, CURLOPT_REFERER, "https://fr.example.com/tn/TUN/myapp.php?fg_id=5622739");
    		curl_setopt($ch, CURLOPT_COOKIEFILE, 'C:\AppServ\www\curl\cookie.txt');
    		curl_setopt($ch, CURLOPT_COOKIEJAR, 'C:\AppServ\www\curl\cookie.txt');
    		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    		curl_setopt($ch, CURLOPT_POST, true);
    		curl_setopt($ch, CURLOPT_POSTFIELDS, $bookrdv);
    		curl_setopt($ch, CURLOPT_VERBOSE, true);
     
    		curl_exec($ch);
     
    		curl_setopt($ch, CURLOPT_URL, 'https://fr.example.com/tn/TUN/myapp.php?fg_id=5622739');
     
            $book = curl_exec($ch);
     
    		echo $book;
     
    			curl_close($ch);
    	?>
    j ai intercépté les requetes post dans le site


    voila comment resemble la requete :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    f_id=&fg_id=5622739what=take_appointment&result=2018-11-09%2009%3A45&as_u_id=&_sid=388fb3bc5d5e4e673d6eb28dfdd34c3b&timestamp=1540935882.7926&skey=674d193848abedb9c96e8b154e9d4413&process=multiconfirm&reloader_timestamp=1540936010233
    Merci les gars je vous attend avec impatience .

  2. #2
    Expert éminent Avatar de CosmoKnacki
    Homme Profil pro
    Justicier interdimensionnel
    Inscrit en
    Mars 2009
    Messages
    2 858
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Charente Maritime (Poitou Charente)

    Informations professionnelles :
    Activité : Justicier interdimensionnel

    Informations forums :
    Inscription : Mars 2009
    Messages : 2 858
    Points : 6 556
    Points
    6 556
    Par défaut
    Tu devrais relire et réécrire ton code pour l'indenter correctement et retirer tout ce qui ne sert à rien. Trouve-toi aussi une convention de nommage de tes variables, de manière à ce qu'on comprenne facilement à quoi elles correspondent.

    Quelle est ta question au juste?
    Brachygobius xanthozonus
    Ctenobrycon Gymnocorymbus

  3. #3
    Membre régulier
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2018
    Messages
    89
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2018
    Messages : 89
    Points : 85
    Points
    85
    Par défaut
    Citation Envoyé par CosmoKnacki Voir le message
    Tu devrais relire et réécrire ton code pour l'indenter correctement et retirer tout ce qui ne sert à rien. Trouve-toi aussi une convention de nommage de tes variables, de manière à ce qu'on comprenne facilement à quoi elles correspondent.

    Quelle est ta question au juste?

    Merci , mais il ya des commentaires elles sont unitule ?

    j'ai bien comenter pour comprendre ce que j 'ai fais .

    voila dans cette partie du code c'est la derniere étape apres avoir tous les parametres nécéssaire pour faire le post,

    je n'ai pas réussi a faire le post

    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
    // dans cette partie du code je n arrive pas a faire le POST 
    		$fieldbook['f_id'] = '';
    	    $fieldbook['fg_id'] = $arrayurl[fg_id];
    		$fieldbook['what'] = $arrayurl[what];
    		$fieldbook['result'] = $arrayurl[result];
    		$fieldbook['as_u_id'] = '';
    		$fieldbook['_sid'] = $secret_id;
    		$fieldbook['timestamp'] = $arrayurl[timestamp];
    		$fieldbook['skey'] = $arrayurl[skey];
    		$fieldbook['process'] = $arrayurl[process];
    		$fieldbook['reloader_timestamp'] = '1540935836428';
     
     
    		$bookrdv = http_build_query($fieldbook);
    		curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
    		curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    		curl_setopt($ch, CURLOPT_URL, $url2);
    		curl_setopt($ch, CURLOPT_REFERER, "https://fr.example.com/tn/TUN/myapp.php?fg_id=5622739");
    		curl_setopt($ch, CURLOPT_COOKIEFILE, 'C:\AppServ\www\curl\cookie.txt');
    		curl_setopt($ch, CURLOPT_COOKIEJAR, 'C:\AppServ\www\curl\cookie.txt');
    		curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    		curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    		curl_setopt($ch, CURLOPT_POST, true);
    		curl_setopt($ch, CURLOPT_POSTFIELDS, $bookrdv);
    		curl_setopt($ch, CURLOPT_VERBOSE, true);
     
    		curl_exec($ch);
     
    		curl_setopt($ch, CURLOPT_URL, 'https://fr.example.com/tn/TUN/myapp.php?fg_id=5622739');
     
            $book = curl_exec($ch);
     
    		echo $book;

    dans cette partie j'ai récuperer les parametres a envoyer


    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
    	$do = new DOMDocument();   // New  dom Doc to Get URL from  disponible dates
    	libxml_use_internal_errors(true);
    	$do->loadHTML($cur);
    	# Parse the HTML
    	# The @ before the method call suppresses any warnings that
    	# loadHTML might throw because of invalid HTML in the page.
    	$xpath = new DOMXPath($do);
    	$onClickAttrNodeList = $xpath->query('//a[@class="dispo"]/@onclick'); //  avoir un tableau qui contient tous les URLS avec des dates disponible
    	preg_match('#var secret_id = (.*)\;#Us', $cur, $out);  //   avoir la secret_id 
    	$secret_id = json_decode($out[1]);  // Get secret ID
     
     
    	$array = array();         // convertir node object a untableau
    	foreach($onClickAttrNodeList as $node){
    		$array[] = $node;
    	}
     
     
    	$x=array();
    	   foreach($array as $node) {
    		   for($i = 0; $i < 20; ++$i) {
    		 $x[] = $node->nodeValue;  //   avoir tous les urls dans un tableau
    	}
     
    	}
    	$randlink = array_rand($x, 20);   //    avoir un URL aléatoir du tableau
    	$link = $x[$randlink[0]];
     
    	echo '<br/>';
    	echo '<br/>';
    	echo $secret_id;
    	echo '<br/>';
    	echo '<br/>';
     
    	echo '<br/>';
    	preg_match_all('#\bhttps?://[^,\s()<>]+(?:\([\w\d]+\)|([^,[:punct:]\s]|/))#', $link, $match);  //avoir un URL  de la derniere list
    	   echo "<pre>";
    	   $url = $match[0];
    	print_r($url[0]); 
     
    	echo'<br/>';
     
    	parse_str( parse_url( $url[0], PHP_URL_QUERY), $arrayurl );   // avoir les parametres de l URL  pour  poster 
     
     
    	var_dump($arrayurl);  //  ici j ai affiché pour tester 
    	echo'<br/>';

    Voila une image j ai réussi a avour tous les parametres



    Nom : Screenshot_6.png
Affichages : 126
Taille : 44,7 Ko



    Voila la requete que j'ai intercepter avec le Brup ,



    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    f_id=&fg_id=5622739what=take_appointment&result=2018-11-09%2009%3A45&as_u_id=&_sid=388fb3bc5d5e4e673d6eb28dfdd34c3b&timestamp=1540935882.7926&skey=674d193848abedb9c96e8b154e9d4413&process=multiconfirm&reloader_timestamp=1540936010233


    Voila ce que affique le site , genre une sécurité ou je sais pas .



    Nom : Screenshot_1.png
Affichages : 131
Taille : 22,0 Ko

    Mercii .

  4. #4
    Membre régulier
    Homme Profil pro
    Étudiant
    Inscrit en
    Avril 2018
    Messages
    89
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 33
    Localisation : Algérie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Avril 2018
    Messages : 89
    Points : 85
    Points
    85
    Par défaut
    Résolu , Merciiii les gars .

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. CURL POST DATA Projet : Autobook appoitment
    Par hocineaminoo dans le forum Langage
    Réponses: 0
    Dernier message: 19/10/2018, 02h14
  2. Post data d'un formulaire Angular 4 en PHP
    Par ghatfan99 dans le forum Général JavaScript
    Réponses: 9
    Dernier message: 18/01/2018, 20h54
  3. Petit cours pour éviter l'envoi POST data d'un formulaire apres un rafraîchissement
    Par maximenet dans le forum Contribuez / Téléchargez Sources et Outils
    Réponses: 8
    Dernier message: 07/10/2006, 00h03
  4. Comment supprimer les post data
    Par jeff_! dans le forum Langage
    Réponses: 4
    Dernier message: 03/08/2006, 10h55
  5. [mysql/php]load Data Infile Pb
    Par toniox dans le forum Requêtes
    Réponses: 13
    Dernier message: 26/06/2006, 16h00

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo