For my project, i'm trying to get the post request on my index.php, edit it with some random values, and then redirect it to another page.
I tried the following:
----------- POST REQUEST -----------
Array
(
[authToken] => 0a65e943412453ecec35c814
[sessionId] => 431503466924
[answers] => [{"Boost":false,"answerTime":1300,"id":3},{"Boost":false,"answerTime":800,"id":1},{"Boost":false,"answerTime":900,"id":3},{"Boost":false,"answerTime":1000,"id":1},{"Boost":false,"answerTime":1200,"id":1}]
[userId] => 2235
)
----------- POST REQUEST -----------
My index.php
<?php
$time=[800,900,1000,1100,1200,1300,1500];
$array = json_decode($_POST['answers'], true);
foreach($array as &$k)
{
$k['answerTime'] =$time[array_rand($time)];
}
$postpop = json_encode($array);
$url = 'http://127.0.0.1/index2.php';
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($postpop));
curl_setopt($ch,CURLOPT_POSTFIELDS,$postpop);
$result = curl_exec($ch);
curl_close($ch);
?>
By doing that, i only get the [answers] on my response.
How can i get to recompile the full request?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…