我正在尝试从我的Unity App发送此JSON Get请求到服务器:
http://192.168.100.54/api/seohardw/%7b%22uuid%22%3a%22b2d31111c283ab159aa3f503fe53bebe952cfe9c%22%2c%22model%22%3a%22Dell+System+XPS+L502X+(Dell+Inc.)%22%2c%22name%22%3a%22LAPTOYIIICWIN%22%2c%22os%22%3a%22Windows+7++(6.1.0)+64bit%22%7d
对此请求进行解码:
http://192.168.100.54/api/seohardw/{"uuid":"b2d31111c283ab159aa3f503fe53bebe952cfe9c","model":"Dell+System+XPS+L502X+(Dell+Inc.)","name":"LAPTOYIIICWIN","os":"Windows+7++(6.1.0)+64bit"}
从我的计算机上完全可以正常按下播放按钮,但是当我编译该应用程序并将其下载到我的android手机中时,则无法正常运行
这是我的网络例程:
IEnumerator SendSeoHardw()
{
string url = ServerURL + "seohardw/";
SeoFields SeoF = new SeoFields();
SeoF.uuid = SystemInfo.deviceUniqueIdentifier;
SeoF.model = SystemInfo.deviceModel;
SeoF.name = SystemInfo.deviceName;
SeoF.os = SystemInfo.operatingSystem;
json = WWW.EscapeURL(JsonUtility.ToJson(SeoF));
Debug.Log(url + json);
WWW www = new WWW(url + json);
yield return www;
json = www.text;
yield return null;
}
关于可能发生的事情的任何想法吗?
关于...
----编辑:-----
我刚刚看到mi服务器日志,请求看起来没有什么不同:
192.168.100.17 - - [08/Jul/2018:16:10:08 -0500] "GET /api/seohardw/%7b%22uuid%22%3a%22b2d31111c283ab159aa3f503fe53bebe952cfe9c%22%2c%22model%22%3a%22Dell+System+XPS+L502X+(Dell+Inc.)%22%2c%22name%22%3a%22LAPTOYIIICWIN%22%2c%22os%22%3a%22Windows+7++(6.1.0)+64bit%22%7d HTTP/1.1" 200 185 "-" "UnityPlayer/2018.1.4f1 (UnityWebRequest/1.0, libcurl/7.51.0-DEV)"
192.168.100.100 - - [08/Jul/2018:16:12:24 -0500] "GET /api/seohardw/%7b%22uuid%22%3a%224e9ba43ae60db57d979031c588a4ad38%22%2c%22model%22%3a%22samsung+GT-I9505%22%2c%22name%22%3a%22%3cunknown%3e%22%2c%22os%22%3a%22Android+OS+7.1.2+%2f+API-25+(NJH47F%2f41b3993b48)%22%7d HTTP/1.1" 404 736 "-" "Dalvik/2.1.0 (Linux; U; Android 7.1.2; GT-I9505 Build/NJH47F)"
----编辑2:-----
我将例程更改为使用UWR,结果是相同的,新例程是这样的:
IEnumerator SendSeoHardw()
{
string url = ServerURL + "seohardw/";
SeoFields SeoF = new SeoFields();
SeoF.uuid = SystemInfo.deviceUniqueIdentifier;
SeoF.model = SystemInfo.deviceModel;
SeoF.name = SystemInfo.deviceName;
SeoF.os = SystemInfo.operatingSystem;
json = WWW.EscapeURL(JsonUtility.ToJson(SeoF));
UnityWebRequest uwr = UnityWebRequest.Get(url + json);
uwr.SetRequestHeader("Content-Type", "application/json; charset=utf-8");
//Send the request then wait here until it returns
yield return uwr.SendWebRequest();
if (uwr.isNetworkError)
{
Debug.Log("Error While Sending: " + uwr.error);
}
else
{
Debug.Log("Received: " + uwr.downloadHandler.text);
}
}