我已经在Stack上阅读了其他一些帖子,但我无法让它发挥作用。当我在我的Windows机器上运行php代码中的curl时它可以正常工作但是当我将它转换为asp.net时它无法正常工作
<%
Dim gv_rand_no, gv_ch, gv_email_id, gv__GET()
gv_rand_no = rand(0,99)
gv_ch = rand(0,99)
gv_email_id = gv__GET("email")
string url = "http://api.mycompany.com/post-api.php";
string data = "{\"id\":9970080, \"email\":\"gv_email_id\",\"method\":2,\"action_id\":110,\"random_number\":\"gv_rand_no\"}";
WebRequest myReq = WebRequest.Create(url);
myReq.Method = "POST";
myReq.ContentLength = data.Length;
myReq.ContentType = "application/json; charset=UTF-8";
using (Stream ds = myReq.GetRequestStream())
{
ds.Write(enc.GetBytes(data), 0, data.Length);
}
WebResponse wr = myReq.GetResponse();
Stream receiveStream = wr.GetResponseStream();
StreamReader reader = new StreamReader(receiveStream, Encoding.UTF8);
string content = reader.ReadToEnd();
Console.WriteLine(content);
Console.ReadLine();
%>
我不熟悉ASP.net。我已使用在线代码转换器转换代码
请帮我这个