PHP中Java的PostMethod的等价物
我想问一下,是否存在一个PHP函数来模拟Codeigniter中的这段代码PHP中Java的PostMethod的等价物,java,php,codeigniter,http-post,Java,Php,Codeigniter,Http Post,我想问一下,是否存在一个PHP函数来模拟Codeigniter中的这段代码 HttpClient httpClient = new HttpClient(); PostMethod postMethod = new PostMethod(requestURL); NameValuePair[] datas = {new NameValuePair("studentnumber", studentnumber),
HttpClient httpClient = new HttpClient();
PostMethod postMethod = new PostMethod(requestURL);
NameValuePair[] datas = {new NameValuePair("studentnumber", studentnumber),
new NameValuePair("studentdata", encryptedData)};
postMethod.setRequestBody(datas);
int statusCode = httpClient.executeMethod(postMethod);
byte[] responseByte = postMethod.getResponseBody();
String responseBody = new String(responseByte, "UTF-8");
curl似乎不起作用,而$this->output->set_output正确地传递数据,但无法捕获requestUrl的响应
谢谢。我能够使用我在上找到的这段代码捕获来自requestUrl的响应(非常感谢)
$options = array(
'http' => array(
'method' => "POST",
'header' => "Accept-language: en\r\n" . "Content-type: application/x-www-form-urlencoded\r\n",
'content' => http_build_query(array(
'studentnumber' => $studentnumber,
'studentdata' => $encryptedData,
),'','&'
)
));
$refno = file_get_contents($requestUrl,false,$context);