也许这是重复的问题。我已经尝试过与我的类似问题的任何解决方案,我可以找到并将其实施到我的问题中,没有一个解决方案是有效的。我需要使用 PHP curl 从其他系统 (B) 获取数据。但是在 B 中,我发送的数据未定义或没有发送数据。curl 过程是成功目标 url 恰到好处。
在我的系统中卷曲
$data['tag'] = 'getData';
$data['periode'] = $this->input->post('periode');
$url = 'http://example.com/service/index.php';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, sizeof($data));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// I use follow location cause I get moved permanently notice
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
在 B 系统中,我检查了这个
var_dump($_POST);
输出是array(0) {}
.
我对此有自己的解决方案。我只需要设置的URLhttps
的insetad http
,因为后台程序重定向所有非安全协议http
的安全一个https
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句