IEnumerator getAPIkey() { UnityWebRequest loginRequest = UnityWebRequest.Get("https://api.vrchat.cloud/api/1/config"); //APIキーをリクエスト yield return(loginRequest.SendWebRequest()); if (loginRequest.isNetworkError || loginRequest.isHttpError) { Debug.Log(loginRequest.error); cam.backgroundColor = new Color(255, 0, 14, 1.0f); } else { vrctwitter.getJson keyJson = JsonUtility.FromJson(loginRequest.downloadHandler.text, typeof(vrctwitter.getJson)) as vrctwitter.getJson; //APIキーを入手 Debug.Log(keyJson.clientApiKey); cam.backgroundColor = new Color(0, 244, 255, 1.0f); variableScript.apikey = keyJson.clientApiKey; //APIキーを記録 } }
IEnumerator getFriend() { UnityWebRequest friendRequest = UnityWebRequest.Get("https://api.vrchat.cloud/api/1/auth/user?apiKey=" + variableScript.apikey); //セッションにログイン yield return(friendRequest.SendWebRequest()); if (friendRequest.isNetworkError || friendRequest.isHttpError) { Debug.Log(friendRequest.error); cam.backgroundColor = new Color(255, 0, 14, 1.0f); } else { vrctwitter.getJson session = JsonUtility.FromJson(friendRequest.downloadHandler.text, typeof(vrctwitter.getJson)) as vrctwitter.getJson; //variableScript.friendInt = session.friends.Length; //フレンド数を記録 variableScript.friendList = session.friends; //フレンドリストを記録 Debug.Log(session.friends.Length); cam.backgroundColor = new Color(0, 244, 255, 1.0f); } }
IEnumerator loginAPI() { UnityWebRequest loginRequest = UnityWebRequest.Get("https://api.vrchat.cloud/api/1/auth/user?apiKey=" + variableScript.apikey); //セッションにログイン loginRequest.SetRequestHeader("ContentType", "application/json"); loginRequest.SetRequestHeader("Authorization", authenticate(variableScript.username, variableScript.password)); //Basic認証 yield return(loginRequest.SendWebRequest()); if (loginRequest.isNetworkError || loginRequest.isHttpError) { Debug.Log(loginRequest.error); cam.backgroundColor = new Color(255, 0, 14, 1.0f); } else { vrctwitter.getJson session = JsonUtility.FromJson(loginRequest.downloadHandler.text, typeof(vrctwitter.getJson)) as vrctwitter.getJson; variableScript.friendInt = session.friends.Length; //フレンド数を記録 variableScript.friendList = session.friends; //フレンドリストを記録 Debug.Log(session.friends.Length); cam.backgroundColor = new Color(0, 244, 255, 1.0f); } }