【发布时间】:2019-12-27 15:35:14
【问题描述】:
我用 Codeigniter 创建了一个简单的 Rest web 服务。 当我从另一个应用程序使用 Curl 发送发布数据并显示 $_POST 为空时。
简单的 PHP 客户端:
$url = 'http://localhost/ci-access/api_v1/register_events';
$data = array(
'name' => 'tester'
);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
$output = curl_exec($ch);
curl_close($ch);
Codeigniter 网络服务:
public function register_events() {
die(var_dump($_POST));
}
是否有在 Codeigniter 中设置的选项? 如何读取发布的数据?
【问题讨论】:
标签: php codeigniter web-services php-curl