|
|
|
@ -1,9 +1,12 @@
|
|
|
|
|
using Stripe.Terminal;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Newtonsoft.Json.Linq;
|
|
|
|
|
using Stripe.Terminal;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Net;
|
|
|
|
|
using System.Net.Http;
|
|
|
|
|
using System.Net.Http.Json;
|
|
|
|
|
using System.Reflection.Metadata;
|
|
|
|
|
using System.Security.Cryptography;
|
|
|
|
|
using System.Security.Policy;
|
|
|
|
@ -16,19 +19,19 @@ namespace WpfApp1.translationKey
|
|
|
|
|
internal class jsonNet
|
|
|
|
|
{
|
|
|
|
|
static string https = "http://api.fanyi.baidu.com/api/trans/vip/translate?";
|
|
|
|
|
|
|
|
|
|
static string trans = "apple";
|
|
|
|
|
static string appid = "20230925001829663";
|
|
|
|
|
|
|
|
|
|
static string trans = "tradition";
|
|
|
|
|
static string appid = "20230925001829663";//20230925001829663,20230923001827495
|
|
|
|
|
static string fl = "en";
|
|
|
|
|
static string dl = "zh";
|
|
|
|
|
static Random rd = new Random();
|
|
|
|
|
static string salt = rd.Next(100000).ToString();
|
|
|
|
|
static string key = "f7ZHpw28izQ1VU_ixoY5";
|
|
|
|
|
static string key = "f7ZHpw28izQ1VU_ixoY5";//f7ZHpw28izQ1VU_ixoY5,yjvMNY33Qc1TYSBjTQYQ
|
|
|
|
|
static string sign = EncryptString(appid + trans + salt + key);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//static HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create("http://api.fanyi.baidu.com/api/trans/vip/translate?q=apple&from=en&to=zh&appid=20230925001829663&salt=1435660288&sign=c963bc2275c0fd1ed30da014c1ef1933");
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
private static HttpClient HttpRe = new HttpClient()
|
|
|
|
|
{
|
|
|
|
@ -46,7 +49,7 @@ namespace WpfApp1.translationKey
|
|
|
|
|
Console.WriteLine($"{jsonResponse}\n");
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static string EncryptString(string str)//百度MD5加密计算方式
|
|
|
|
|
{
|
|
|
|
|
MD5 md5 = MD5.Create();
|
|
|
|
@ -64,10 +67,15 @@ namespace WpfApp1.translationKey
|
|
|
|
|
// 返回加密的字符串
|
|
|
|
|
return sb.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void requestJson()
|
|
|
|
|
{
|
|
|
|
|
string temp = "q=" + HttpUtility.UrlEncode(trans) + "&from" + fl + "&to" + dl + "&appid" + appid + "&salt" + salt + "&sign" + sign;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
string temp = "q=" + HttpUtility.UrlEncode(trans) + "&from=" + fl + "&to=" + dl + "&appid=" + appid + "&salt=" + salt + "&sign=" + sign;
|
|
|
|
|
Console.WriteLine(https + temp);
|
|
|
|
|
//Task t = GetAsync(HttpRe); t.Wait();
|
|
|
|
|
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(https + temp);
|
|
|
|
|
request.Method = "GET";
|
|
|
|
@ -75,12 +83,26 @@ namespace WpfApp1.translationKey
|
|
|
|
|
request.UserAgent = null;
|
|
|
|
|
request.Timeout = 6000;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var response = request.GetResponse();
|
|
|
|
|
var myResponseStream = response.GetResponseStream();
|
|
|
|
|
var myStreamReader = new StreamReader(myResponseStream, Encoding.GetEncoding("utf-8"));
|
|
|
|
|
string retString = myStreamReader.ReadToEnd();
|
|
|
|
|
Console.WriteLine(retString);
|
|
|
|
|
}
|
|
|
|
|
tempC2 temp1 = JsonConvert.DeserializeObject<tempC2>(retString);
|
|
|
|
|
Trans_result result = temp1.trans_result[0];
|
|
|
|
|
string s = result.dst;
|
|
|
|
|
Console.WriteLine(s);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public class Trans_result
|
|
|
|
|
{
|
|
|
|
|
public string src { get; set; }
|
|
|
|
|
public string dst { get; set; }
|
|
|
|
|
}
|
|
|
|
|
public class tempC2
|
|
|
|
|
{
|
|
|
|
|
public List<Trans_result> trans_result { get; set; }
|
|
|
|
|
}
|
|
|
|
|
}
|