WWWForm form = new WWWForm();
form.AddField("username", "admin");
form.AddField("password", "pass");
form.AddField(key1, value1);
form.AddField(key2, value2);
form.AddField(key3, value3);
string realToken = "";
using (UnityWebRequest www = UnityWebRequest.Post(tokenURL, form))
{
yield return www.SendWebRequest();
if (www.isNetworkError || www.isHttpError)
{
Debug.Log(www.error);
}
else
{
byte[] token = www.downloadHandler.data;
string result1 = Encoding.Default.GetString(token);
string result = System.Text.Encoding.UTF8.GetString(token);
Debug.Log(www.downloadHandler.text);
Debug.Log("result1 = " + result1);
Debug.Log("result = " + result);
}
}
Unity的输出:
{ “标记”: “HaFfPZi3GRhJJDbIdH6Oze2o0ToctdU7-nnzIhnWyZA”, “过期”:1528242946005}
result1 = { “标记”: “HaFfPZi3GRhJJDbIdH6Oze2o0ToctdU7-nnzIhnWyZA”, “过期”:1528242946005}
结果= { “标记”: “HaFfPZi3GRhJJDbIdH6Oze2o0ToctdU7-nnzIhnWyZA”, “过期”:1528242946005}
我想要的是长“HaFfPZ .....”字符串,但它始终以“。”结尾。 (从不在浏览器值中)并切断该值的剩余数据。例如,浏览器中的相同数据类似于:
{ “标记”: “HaFfPZi3GRhJJDbIdH6OzWy0JIOYDJ84ABYvu9pBcOQVnXPdltJhn0ILjBdpZp8Z”, “过期”:1528243370083}
似乎单位值返回大约43个字符,浏览器值返回64个字符。
有什么想法吗?