【问题标题】:RePost (bounce) received datas the same using curl使用 curl 重新发布(反弹)接收到的数据相同
【发布时间】:2017-07-03 20:50:53
【问题描述】:

有谁知道如何退回(重新发布,完全相同的方式)以前发布到我的页面的数组(数据)?

这是我现在的做法,猜这不是最好的方法:

收到的数据

$_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);
 $result = curl_exec($ch);

有人有想法吗?请;)

【问题讨论】:

  • 你为什么用$_REQUEST而不是$_POST
  • 有时数据来自 $_GET

标签: php curl post bounce


【解决方案1】:

如果您想重新发布来自GETPOST 的数据,您的代码几乎完成了。只需添加curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

所以,代码会是这样的

$_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);

【讨论】:

    猜你喜欢
    • 2015-03-26
    • 1970-01-01
    • 2012-04-03
    • 2014-01-22
    • 1970-01-01
    • 1970-01-01
    • 2018-01-26
    • 2016-02-18
    • 2013-09-09
    相关资源
    最近更新 更多