只是说我想保存的价值
POST` method "[https://api.dropbox.com/1/oauth/request_token][1]"
在一个叫做
`accessToken` of type `string`
(lets just asume that the post method retuns string for the sake of simplicity)
在C#中..该怎么做?
首先,您必须对字符串变量进行贴花处理,如下所示:
string httpReturnValue = "";
要获取值并将其存储在字符串中,您必须执行以下操作:
var request = (HttpWebRequest)WebRequest.Create("YOUR URL");
// For example
var postData = "thing1=hello";
postData += "&thing2=world";
var data = Encoding.ASCII.GetBytes(postData);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = data.Length;
using (var stream = request.GetRequestStream())
{
stream.Write(data, 0, data.Length);
}
var response = (HttpWebResponse)request.GetResponse();
var httpReturnValue= new StreamReader(response.GetResponseStream()).ReadToEnd();
代码来自这里:带有post的HTTP请求。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句