我试图在php中复制以下内容虽然我被困在Encoding.ASCII.GetBytes(paramList)
HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
string paramList = "paramList=ThruDate_" + thruDate.ToString() + "|OwnerLevel_" + ownerLevel;
Stream stream = req.GetRequestStream();
byte[] bytes = Encoding.ASCII.GetBytes(paramList);
stream.Write(bytes, 0, bytes.Length);
stream.Close();
答案 0 :(得分:0)
使用php时,不需要获取一个字节数组就可以将POST数据发送到某个http服务器。
$postdata = "something=something";
$ctx = stream_context_create(array(
'http'=>array(
'method'=>'POST'
'content'=>$postdata,
'header' => 'Content-type: application/x-www-form-urlencoded'
)
));
$responsedata = file_get_contents('http://...', false, $ctx);
另见:
http://docs.php.net/file_get_contents
http://docs.php.net/context.http