PHP 中 Java 的 PostMethod 的等价物
Equivalent of PostMethod of Java in PHP
想请问在Codeigniter中有没有PHP函数来模拟这段代码
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);
想请问在Codeigniter中有没有PHP函数来模拟这段代码
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);