public string postparameter (string url)
{string Message= "";
Getorderinfomation order=new getorderinfomation ();
String Parameter = "orderno=" + order. Getordernos () + "&receiptdata=test&result=\" status\ "=\" 0\ "; \r\n\ "product_id\" =\ "2\"; \r\n\ "transaction_id\" =\ "3\"; \r\n\ "bid\" =\ "4\" ";
byte[] bytes = Encoding.UTF8.GetBytes (Parameter);
GetConfig con = new GetConfig ();
String prfix = con. urlprefix;//Get address prefixes
String strURL = Prfix + url;//Create an Access address
HttpWebRequest request = (HttpWebRequest) webrequest.create (strURL);
Request. Method = "POST";
Request. contentlength = bytes. Length;
Request. ContentType = "Text/xml";
using (Stream requeststream = Request. GetRequestStream ())
{
requestStream.Write (bytes, 0, bytes. Length);
}
HttpWebResponse response = (HttpWebResponse) request. GetResponse ();
StreamReader sr = new StreamReader (response. GetResponseStream ());
String jsonstr = Sr. ReadToEnd ();
return jsonstr;
if (response. StatusCode! = Httpstatuscode.ok)
{
Return "POST failed. Received http+ "+ response. StatusCode + "";
}
}
Processing Requests//Receive receipt-data on the URL page
byte[] Byts = new Byte[request.inputstream.length];
Request.InputStream.Read (Byts, 0, Byts. Length);
Sreceiptdata = System.Text.Encoding.Default.GetString (Byts);
string[] Data = Sreceiptdata.split (' & ');//Get the number of references
GET request
public string Response (string url)
{
Try
{
GetConfig con = new GetConfig ();
String prfix = con. urlprefix;//Get address prefixes
String strURL = Prfix + url;//Create an Access address
System.Net.HttpWebRequest request;
Request = (System.Net.HttpWebRequest) webrequest.create (strURL);//Create an HTTP request
Request. Method = "get";//Send Request
System.Net.HttpWebResponse response;
Response = (System.Net.HttpWebResponse) request. GetResponse ();//Get response
StreamReader sr = new StreamReader (response. GetResponseStream ());
String jsonstr = Sr. ReadToEnd ();
return jsonstr;
}
catch (Exception)
{
Return "The server connection error.";
}
}
Http post submission and get commit