$urls = array( 'http://www.example.com/1.html', 'http://www.example.com/2.html', ); $api = 'http://data.zz.baidu.com/urls?site=https://3gqq.cn&token=LA8UpYR7d3zCQ2RL'; $ch = curl_init(); $options = array( CURLOPT_URL => $api, CURLOPT_POST => true, CURLOPT_RETURNTRANSFER => true, CURLOPT_POSTFIELDS => implode("\n", $urls), CURLOPT_HTTPHEADER => array('Content-Type: text/plain'), ); curl_setopt_array($ch, $options); $result = curl_exec($ch); echo $result;翻译成asp.net源码
时间: 2024-03-07 16:51:02 浏览: 161
以下是将上述PHP代码翻译成ASP.NET的源代码:
```
string[] urls = new string[] {
"http://www.example.com/1.html",
"http://www.example.com/2.html"
};
string api = "http://data.zz.baidu.com/urls?site=https://3gqq.cn&token=LA8UpYR7d3zCQ2RL";
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(api);
request.Method = "POST";
request.ContentType = "text/plain";
using (StreamWriter writer = new StreamWriter(request.GetRequestStream())) {
writer.Write(string.Join("\n", urls));
}
string result;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
using (StreamReader reader = new StreamReader(response.GetResponseStream())) {
result = reader.ReadToEnd();
}
}
Console.WriteLine(result);
```
阅读全文