【发布时间】:2017-08-23 18:16:15
【问题描述】:
对于我的项目,我正在尝试在我的 index.php 上获取发布请求,使用一些随机值对其进行编辑,然后将其重定向到另一个页面。
我尝试了以下方法:
----------- 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 -----------
我的 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);
?>
通过这样做,我只能在我的回复中得到 [答案]。 我怎样才能重新编译完整的请求?
【问题讨论】:
-
您在 SO 上有多少个帐户,@JohnSnow? stackoverflow.com/q/45829570/2943403 当我真正想帮助您时,您从其他问题中复制粘贴我的代码(不奖励我的努力甚至评论)似乎有点粗鲁。
-
如果你对我的代码块有任何疑问,你应该问我——因为我写了它。