发新话题 回复该主题

求教一下,C#伪原创变量的问题 [复制链接]

1#
已在Vg建立变量{-var.内容-},需要运营平台放提供的C#语句对变量“内容”进行伪原创并保存为新变量 “伪原创”,本人是菜鸟,不懂C#请大佬帮忙完善一下。
以下为平台提供的C#:
  1.         using System.IO;
  2.         using System.Text;
  3.         using System.Net;
  4.         using System.Net.Security;
  5.         using System.Security.Cryptography.X509Certificates;
  6.         private const String host = "http://apis.5118.com";
  7.         private const String path = "/wyc/sentence";
  8.         private const String method = "POST";
  9.         private const String apikey = "你要调用的接口apikey";
  10.         static void Main(string[] args)
  11.         {
  12.             String querys = "";
  13.             String bodys = "txt=txt";
  14.             String url = host + path;
  15.             HttpWebRequest httpRequest = null;
  16.             HttpWebResponse httpResponse = null;
  17.             if (0 < querys.Length)
  18.             {
  19.                 url = url + "?" + querys;
  20.             }
  21.             if (host.Contains("https://"))
  22.             {
  23.                 ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
  24.                 httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
  25.             }
  26.             else
  27.             {
  28.                 httpRequest = (HttpWebRequest)WebRequest.Create(url);
  29.             }
  30.             httpRequest.Method = method;
  31.             httpRequest.Headers.Add("Authorization", apikey);
  32.             //根据API的要求,定义相对应的Content-Type
  33.             httpRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
  34.             if (0 < bodys.Length)
  35.             {
  36.                 byte[] data = Encoding.UTF8.GetBytes(bodys);
  37.                 using (Stream stream = httpRequest.GetRequestStream())
  38.                 {
  39.                     stream.Write(data, 0, data.Length);
  40.                 }
  41.             }
  42.             try
  43.             {
  44.                 httpResponse = (HttpWebResponse)httpRequest.GetResponse();
  45.             }
  46.             catch (WebException ex)
  47.             {
  48.                 httpResponse = (HttpWebResponse)ex.Response;
  49.             }
  50.             Console.WriteLine(httpResponse.StatusCode);
  51.             Console.WriteLine(httpResponse.Method);
  52.             Console.WriteLine(httpResponse.Headers);
  53.             Stream st = httpResponse.GetResponseStream();
  54.             StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
  55.             Console.WriteLine(reader.ReadToEnd());
  56.             Console.WriteLine("\n");
  57.         }
  58.         public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
  59.         {
  60.             return true;
  61.         }
复制代码
网走过路过的大佬帮忙写一下呀~
分享 转发
TOP
发新话题 回复该主题