已在Vg建立变量{-var.内容-},需要运营平台放提供的C#语句对变量“内容”进行伪原创并保存为新变量 “伪原创”,本人是菜鸟,不懂C#请大佬帮忙完善一下。
以下为平台提供的C#:
- using System.IO;
- using System.Text;
- using System.Net;
- using System.Net.Security;
- using System.Security.Cryptography.X509Certificates;
- private const String host = "http://apis.5118.com";
- private const String path = "/wyc/sentence";
- private const String method = "POST";
- private const String apikey = "你要调用的接口apikey";
- static void Main(string[] args)
- {
- String querys = "";
- String bodys = "txt=txt";
- String url = host + path;
- HttpWebRequest httpRequest = null;
- HttpWebResponse httpResponse = null;
- if (0 < querys.Length)
- {
- url = url + "?" + querys;
- }
- if (host.Contains("https://"))
- {
- ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
- httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url));
- }
- else
- {
- httpRequest = (HttpWebRequest)WebRequest.Create(url);
- }
- httpRequest.Method = method;
- httpRequest.Headers.Add("Authorization", apikey);
- //根据API的要求,定义相对应的Content-Type
- httpRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
- if (0 < bodys.Length)
- {
- byte[] data = Encoding.UTF8.GetBytes(bodys);
- using (Stream stream = httpRequest.GetRequestStream())
- {
- stream.Write(data, 0, data.Length);
- }
- }
- try
- {
- httpResponse = (HttpWebResponse)httpRequest.GetResponse();
- }
- catch (WebException ex)
- {
- httpResponse = (HttpWebResponse)ex.Response;
- }
- Console.WriteLine(httpResponse.StatusCode);
- Console.WriteLine(httpResponse.Method);
- Console.WriteLine(httpResponse.Headers);
- Stream st = httpResponse.GetResponseStream();
- StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8"));
- Console.WriteLine(reader.ReadToEnd());
- Console.WriteLine("\n");
- }
- public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors)
- {
- return true;
- }
复制代码网走过路过的大佬帮忙写一下呀~