后置参数失败


POST PARAMETERS FAIL

我需要使用curl来调用一些API,这是我的函数:

$url = ........
$curl_data = array('name'=>$name);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $curl_data);
$output = curl_exec($ch);
$info = curl_getinfo($ch, CURLINFO_HTTP_CODE);

这是我用curl调用中的url调用的函数:

function getFunction() {
        $name = $this->input->post ( 'name' );
}

但是当我打印"$name"时,我读取的值为空。有人能帮我吗?

您需要设置curl选项才能使用POST方法。CURLOPT_POST-

http://php.net/manual/en/function.curl-setopt.php