2017-07-03 2 views
0

Est-ce que quelqu'un sait Comment faire rebondir (RePost, exactement de la même manière) un tableau (données) précédemment publié sur ma page?RePost (bounce) les données reçues le même en utilisant curl

Voici comment je fais maintenant, devinez ce n'est pas la meilleure façon:

données reçues

$_datas = $_REQUEST; 

et comment republier?

$ch = curl_init(); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_URL, 'http://website.com/new_script.php'); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $_datas); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
$result = curl_exec($ch); 

Quelqu'un a une idée? S'il vous plaît;)

+0

Pourquoi utilisez-vous '_REQUEST' $ au lieu de' $ _POST'? –

+0

Parfois, les données sont en $ _GET – Thierry

Répondre

0

Si vous voulez données réafficher qui vient en GET et POST, votre code presque complet. Juste besoin d'ajouter curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

Ainsi, le code sera comme celui-ci

$_datas = $_REQUEST; 
$ch = curl_init(); 
curl_setopt($ch, CURLOPT_POST, 1); 
curl_setopt($ch, CURLOPT_URL, 'http://website.com/new_script.php'); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $_datas); 
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
$result  = curl_exec($ch); 
$statusCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 
curl_close($ch); 
+0

Merci beaucoup! Ça marche – Thierry