Pages :
(reprise du message précédent)

<?php
$infos['login'] = "X";
$infos['password'] = "Y";
$ch = curl_init();
					curl_setopt( $ch, CURLOPT_URL, "https://ws.colissimo.fr/widget-point-retrait/rest/authenticate.rest");
					curl_setopt( $ch, CURLOPT_HEADER, FALSE );
					curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE );
					curl_setopt( $ch, CURLOPT_POST, TRUE );
					curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE);
				    curl_setopt( $ch, CURLOPT_VERBOSE, 1);
				    curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 2);
					curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($infos));
					$REPONSE = curl_exec( $ch );
					curl_close( $ch );

					echo $REPONSE;  // pour voir la réponse de la poste
$result = json_decode($REPONSE, true);
$token = $result['token'];
echo $token;  // pour voir si t'as bien un token
?>

<!DOCTYPE html> 
<html lang="fr">
    <head>
        <title>Front Page Point Retrait</title> 
        <meta charset="utf-8"> 
        <meta http-equiv="pragma" content="no-cache" /> 
        <meta http-equiv="cache-control" content="no-cache" /> 
        <meta http-equiv="Expires" content="0" /> 
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.js" type="text/javascript"></script>
        <script src="https://ws.colissimo.fr/widget-point-retrait/resources/js/jquery.plugin.colissimo.min.js" type="text/javascript"></script> 
    </head> 
    <body> 
        <h1>Le haut de la page</h1> 
      <script type="text/javascript">
$(function() {

	$.post("https://ws.colissimo.fr/widget-point-retrait/rest/authenticate.rest", {login:"X", password:"Y"}, function(leRetour){

		console.log(leRetour);
		transfo = $.parseJSON(leRetour);
		leToken = transfo['token'];
		$('#widget-container').frameColissimoOpen(
		{
            "ceLang":"FR",
			"callBackFrame":'callBackFrame',
			"URLColissimo":"https://ws.colissimo.fr",
			"ceCountryList":"FR,ES,GB,PT,DE",
			"ceCountry":"FR",
			"dyPreparationTime":"1",
			"ceAddress":"62 RUE CAMILLE DESMOULINS",
			"ceZipCode":"92130",
			"ceTown":"ISSY LES MOULINEAUX",
			"token":leToken
		});
	});
	

	});
function callBackFrame(point) {
	console.log('call back frame');
	console.log(point);
}
</script>
        <div id="widget-container" ></div> 
        <input type="hidden" id="pudoWidgetErrorCode"> 
        <h1>Le bas de la page</h1>
        </body>
</html>



Je commence à piger le truc.
Modifié par Tintin75 (25 May 2018 - 09:39)
alors oui mais non Smiley lol
Plus besoin du token dan sle JS et du coup la variable du token c'est du PHP pas du JS donc :


<script type="text/javascript">
$(function() {

	leToken = <?=$token?>;
		$('#widget-container').frameColissimoOpen(
		{
            "ceLang":"FR",
			"callBackFrame":'callBackFrame',
			"URLColissimo":"https://ws.colissimo.fr",
			"ceCountryList":"FR,ES,GB,PT,DE",
			"ceCountry":"FR",
			"dyPreparationTime":"1",
			"ceAddress":"62 RUE CAMILLE DESMOULINS",
			"ceZipCode":"92130",
			"ceTown":"ISSY LES MOULINEAUX",
			"token":leToken
		});
	});
	

	});
function callBackFrame(point) {
	console.log('call back frame');
	console.log(point);
}
</script>
<?php
$infos['login'] = "X";
$infos['password'] = "Y";
$ch = curl_init();
					curl_setopt( $ch, CURLOPT_URL, "https://ws.colissimo.fr/widget-point-retrait/rest/authenticate.rest");
					curl_setopt( $ch, CURLOPT_HEADER, FALSE );
					curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE );
					curl_setopt( $ch, CURLOPT_POST, TRUE );
					curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE);
				    curl_setopt( $ch, CURLOPT_VERBOSE, 1);
				    curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 2);
					curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($infos));
					$REPONSE = curl_exec( $ch );
					curl_close( $ch );
	
$result = json_decode($REPONSE, true);
$token = $result['token'];
?>

<!DOCTYPE html> 
<html lang="fr">
    <head>
        <title>Front Page Point Retrait</title> 
        <meta charset="utf-8"> 
        <meta http-equiv="pragma" content="no-cache" /> 
        <meta http-equiv="cache-control" content="no-cache" /> 
        <meta http-equiv="Expires" content="0" /> 
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.js" type="text/javascript"></script>
        <script src="https://ws.colissimo.fr/widget-point-retrait/resources/js/jquery.plugin.colissimo.min.js" type="text/javascript"></script> 
    </head> 
    <body> 
        <h1>Le haut de la page</h1> 
    <script type="text/javascript">
$(function() {

	leToken = <?php=$token?>;
		$('#widget-container').frameColissimoOpen(
		{
            "ceLang":"FR",
			"callBackFrame":'callBackFrame',
			"URLColissimo":"https://ws.colissimo.fr",
			"ceCountryList":"FR,ES,GB,PT,DE",
			"ceCountry":"FR",
			"dyPreparationTime":"1",
			"ceAddress":"62 RUE CAMILLE DESMOULINS",
			"ceZipCode":"92130",
			"ceTown":"ISSY LES MOULINEAUX",
			"token":leToken
		});
	});
	

	});
function callBackFrame(point) {
	console.log('call back frame');
	console.log(point);
}
</script>
        <div id="widget-container" ></div> 
        <input type="hidden" id="pudoWidgetErrorCode"> 
        <h1>Le bas de la page</h1>
        </body>
</html>



Je dois pas être loin, ça me plait bien.
C'est :
leToken = <?=$token?>; ou
leToken = <?php=$token?>;
Modifié par Tintin75 (25 May 2018 - 09:57)
soit tu fais

leToken = <?=$token?>;

ou

leToken = <? echo $token; ?>;


et en même temps je te donnes une écriture ?? pourquoi tu la modifie ??
Modifié par pchlj (25 May 2018 - 10:02)
Ni l'un ni l'autre ne fonctionne. Le code est bon ?

C'est du php, on doit pas mettre <?php derrière ?
Modifié par Tintin75 (25 May 2018 - 10:03)
ceci <?=$token?>; est strictement pareil que cela <? echo $token; ?>;

bah par défaut oui le code est bon après est ce que curl est activé sur ton serveur ?
<?php
$infos['login'] = "X";
$infos['password'] = "Y";
$ch = curl_init();
					curl_setopt( $ch, CURLOPT_URL, "https://ws.colissimo.fr/widget-point-retrait/rest/authenticate.rest");
					curl_setopt( $ch, CURLOPT_HEADER, FALSE );
					curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE );
					curl_setopt( $ch, CURLOPT_POST, TRUE );
					curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE);
				    curl_setopt( $ch, CURLOPT_VERBOSE, 1);
				    curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 2);
					curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($infos));
					$REPONSE = curl_exec( $ch );
					curl_close( $ch );

$result = json_decode($REPONSE, true);
$token = $result['token'];

?>

<!DOCTYPE html> 
<html lang="fr">
    <head>
        <title>Front Page Point Retrait</title> 
        <meta charset="utf-8"> 
        <meta http-equiv="pragma" content="no-cache" /> 
        <meta http-equiv="cache-control" content="no-cache" /> 
        <meta http-equiv="Expires" content="0" /> 
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.js" type="text/javascript"></script>
        <script src="https://ws.colissimo.fr/widget-point-retrait/resources/js/jquery.plugin.colissimo.min.js" type="text/javascript"></script> 
    </head> 
    <body> 
        <h1>Le haut de la page</h1> 
    <script type="text/javascript">
$(function() {

	leToken = <?=$token?>;
		$('#widget-container').frameColissimoOpen(
		{
            "ceLang":"FR",
			"callBackFrame":'callBackFrame',
			"URLColissimo":"https://ws.colissimo.fr",
			"ceCountryList":"FR,ES,GB,PT,DE",
			"ceCountry":"FR",
			"dyPreparationTime":"1",
			"ceAddress":"62 RUE CAMILLE DESMOULINS",
			"ceZipCode":"92130",
			"ceTown":"ISSY LES MOULINEAUX",
			"token":leToken
		});
	});
	

	});
function callBackFrame(point) {
	console.log('call back frame');
	console.log(point);
}
</script>
        <div id="widget-container" ></div> 
        <input type="hidden" id="pudoWidgetErrorCode"> 
        <h1>Le bas de la page</h1>
        </body>
</html>
Ligne 18

Ca viendrait de : $token = $result['token'];

à mon avis
Modifié par Tintin75 (25 May 2018 - 10:35)
Modérateur
Salut,

Pour le savoir, remplace la ligne
$token = $result['token'];

par
print_r($result);


et poste-nous le résultat du print Smiley smile
Modérateur
Et ceci, renvoi quoi ?
<?php
$infos['login'] = "X";
$infos['password'] = "Y";
$ch = curl_init();
					curl_setopt( $ch, CURLOPT_URL, "https://ws.colissimo.fr/widget-point-retrait/rest/authenticate.rest");
					curl_setopt( $ch, CURLOPT_HEADER, FALSE );
					curl_setopt( $ch, CURLOPT_RETURNTRANSFER, TRUE );
					curl_setopt( $ch, CURLOPT_POST, TRUE );
					curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, FALSE);
				    curl_setopt( $ch, CURLOPT_VERBOSE, 1);
				    curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 2);
					curl_setopt( $ch, CURLOPT_POSTFIELDS, json_encode($infos));
					$REPONSE = curl_exec( $ch );
					curl_close( $ch );

if ($REPONSE === true) { echo 'Renvoi true !<br>'; }
elseif ($REPONSE === false) { echo 'Renvoi false !<br>'; }
else { echo 'Renvoi : '.$REPONSE.' !<br>'; }


//$result = json_decode($REPONSE, true);
//$token = $result['token'];

?>
Pages :