|
| 1 | +using System; |
| 2 | +using System.Collections; |
| 3 | +using System.Collections.Generic; |
| 4 | +using System.Web; |
| 5 | +using UnityEngine; |
| 6 | +using UnityEngine.Networking; |
| 7 | +using UnityEngine.SceneManagement; |
| 8 | + |
| 9 | +public class SupportPhoneStat : MonoBehaviour |
| 10 | +{ |
| 11 | + // Start is called before the first frame update |
| 12 | + void Start() |
| 13 | + { |
| 14 | + StartCoroutine(ReportEnterScene()); |
| 15 | + |
| 16 | + } |
| 17 | + |
| 18 | + IEnumerator ReportEnterScene() |
| 19 | + { |
| 20 | + string phoneId = SystemInfo.deviceUniqueIdentifier; |
| 21 | + string phoneType = SystemInfo.deviceModel; |
| 22 | + string androidVersion = SystemInfo.operatingSystem; |
| 23 | + int sceneNumber = SceneManager.GetActiveScene().buildIndex; |
| 24 | + int appVersion = 1; |
| 25 | + int random = UnityEngine.Random.Range(int.MinValue, int.MaxValue); |
| 26 | + |
| 27 | + string url = "http://noodle1983.gz01.bdysite.com/index.php/PatchRecord/login?"; |
| 28 | + string param = "phone_id=" + Uri.EscapeDataString(phoneId) |
| 29 | + + "&phone_type=" + Uri.EscapeDataString(phoneType) |
| 30 | + + "&android_version=" + Uri.EscapeDataString(androidVersion) |
| 31 | + + "&enter_scene=" + sceneNumber |
| 32 | + + "&app_version=" + appVersion |
| 33 | + + "&rand=" + random; |
| 34 | + string req = url + param; |
| 35 | + Debug.Log(req); |
| 36 | + |
| 37 | + UnityWebRequest www = UnityWebRequest.Get(req); |
| 38 | + www.SetRequestHeader("User-Agent", "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.103 Safari/537.36"); |
| 39 | + yield return www.SendWebRequest(); |
| 40 | + |
| 41 | + if (www.isNetworkError || www.isHttpError) |
| 42 | + { |
| 43 | + Debug.Log(www.error); |
| 44 | + } |
| 45 | + else |
| 46 | + { |
| 47 | + // Show results as text |
| 48 | + Debug.Log(www.downloadHandler.text); |
| 49 | + |
| 50 | + // Or retrieve results as binary data |
| 51 | + byte[] results = www.downloadHandler.data; |
| 52 | + } |
| 53 | + } |
| 54 | +} |
0 commit comments