Adds a simple field to the form.
private WWWForm AddParams() { WWWForm form = new WWWForm(); form.AddField( GameConstants.REQUEST_KEY_API_KEY, Encryption.API_KEY); form.AddField( GameConstants.REQUEST_KEY_TIMESTAMP, "" + (DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond)); return form; }
public IEnumerator Authenticate(string gameId, string hostname, int httpPort, string username, string password, Success success, Error error) { string prefix; if (NetworkSettings.instance.httpUseSSL) { prefix = "https://"; } else { prefix = "http://"; } string uri = prefix + hostname + ":" + httpPort + "/api/client/login/" + gameId; //Debug.Log ("Authenticating via " + uri); var form = new WWWForm (); form.AddField ("username", username); form.AddField ("password", password); WWW www = new WWW (uri, form.data, form.headers); yield return www; if (www.error != null) { Debug.Log(www.error); error (www.error); } else { //Debug.Log(www.text); Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>> (www.text); success (values); } }
IEnumerator GetNewTrades() { WWWForm form = new WWWForm(); form.AddField("_Token", APIKey); //The token form.AddField("Symbols", symbols); //The Symbols you want DateTimeOffset currentTimeEST = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, easternZone); form.AddField("StartDateTime", lastUpdatedEST.ToString(timeFormat)); //The proper DateTime in the proper format form.AddField("EndDateTime", currentTimeEST.AddTicks(-1000000).ToString(timeFormat)); //The proper DateTime in the proper format var url = "http://ws.nasdaqdod.com/v1/NASDAQTrades.asmx/GetTrades HTTP/1.1"; WWW www = new WWW(url, form); yield return www; if (www.error == null) { //Sucessfully loaded the JSON string Debug.Log("Loaded following JSON string" + www.text); } else { Debug.Log("ERROR: " + www.error); } }
/** * Creates a new player account */ public void Register(string name, string pass, Action<JSONObject> success, Action<string> error) { WWWForm form = new WWWForm(); form.AddField("name", name); form.AddField("pass", Util.Encrypt(pass)); t.Post("player/register", form, success, error); }
/** * Adds a new game to the network */ public void Register(string name, string dev, string url, Action<JSONObject> success, Action<string> error) { WWWForm form = new WWWForm(); form.AddField("name", name); form.AddField("dev", dev); form.AddField("url", url); t.Post("game/register", form, success, error); }
public void Login(string username, string password) { WWWForm form = new WWWForm(); form.AddField("username", username); form.AddField("password", password); httpService.HttpPost(LOGIN_URL, form, LoginCallback); }
public void Register(string username, string password, string email) { WWWForm form = new WWWForm(); form.AddField("username", username); form.AddField("password", password); form.AddField("email", email); httpService.HttpPost(REGISTRATION_URL, form, RegistrationCallback); }
public void AccountLoginCorrect(string username, string pwd) { string salt = ""; string CorrectHashedPwd = ""; string answer = ""; password = pwd; UnityEngine.WWWForm form = new UnityEngine.WWWForm(); form.AddField("Command", "GetHashSalt"); form.AddField("acctName", username); WWWLoader.instance.myDelegate += OnGetHashAndSalt; WWWLoader.Load("http://unitytowerdefense.com/WebService.php", form); }
//Data is sent using HTTP GET public void SendData(string data) { WWWForm formData = new WWWForm(); formData.AddField("userid", _ID); formData.AddField("appversion", _AppVersion); formData.AddField("data", data); if (Reta.DEBUG_ENABLED && Reta.Instance.onDebugLog != null) Reta.Instance.onDebugLog("[Reta] Sending Data " + data + " to " + _ID); //Create URL StartCoroutine(SendingData(formData)); }
public static void SendBuildEvent() { Settings settings = Settings.Instance; Utils.Log ("Sending build information"); #if UNITY_CLOUD_BUILD settings.Organization.ApiKey = "ffb52e2b5f4b59267466b65b90a7bf0e7f9c6190"; #else if (string.IsNullOrEmpty(settings.Organization.ApiKey)) { Utils.Error ("API key not found"); return; } #endif var bundleId = PlayerSettings.bundleIdentifier; WWWForm form = new WWWForm(); form.AddField("app_name", bundleId); form.AddField("app_identifier", bundleId); form.AddField("base_identifier", bundleId); form.AddField("platform_id", "android"); var headers = new Dictionary<string, string> (); headers.Add("X-CRASHLYTICS-DEVELOPER-TOKEN", "771b48927ee581a1f2ba1bf60629f8eb34a5b63f"); headers.Add("X-CRASHLYTICS-API-KEY", settings.Organization.ApiKey); headers.Add("X-CRASHLYTICS-API-CLIENT-ID", "io.fabric.tools.unity"); headers.Add("X-CRASHLYTICS-API-CLIENT-DISPLAY-VERSION", "1.0.0"); string url = "https://api.crashlytics.com/spi/v1/platforms/android/apps/" + bundleId + "/built"; byte[] rawData = form.data; WWW www = new WWW(url, rawData, headers); var timeout = false; var t0 = DateTime.UtcNow; while (!www.isDone) { var t1 = DateTime.UtcNow; var delta = (int)(t1-t0).TotalSeconds; if (delta > 5) { timeout = true; break; } }; if (timeout) { Utils.Warn ("Timed out waiting for build event response. If this is a production build, you may want to build again to ensure it has been properly sent."); } else if (string.IsNullOrEmpty(www.error)) { Utils.Log ("Build information sent"); } else { Utils.Error ("Could not send build event. Error: " + www.error); } }
public void Character() { _log = "Loading..."; WWWForm form = new WWWForm(); form.AddField("u900151974_login", username); form.AddField("u900151974_pass", pswd); connect = new WWW(getCharacter, form); StartCoroutine(WaitForRequestCharacter(connect)); }
public static IEnumerator Login() { if (Credentials.user_email != "" && Credentials.user_password != "") { LWInterface.NewNotification("Attempting to log in..", LWInterface.Notification.LWNotificationType.Message); WWWForm requestForm = new WWWForm(); requestForm.AddField("email", Credentials.user_email); requestForm.AddField("password", Credentials.user_password); WWW request = new WWW(Domain, requestForm); yield return request; string requestText = request.text; if (requestText != "NLI") { string[] creds; char delim = '&'; creds = requestText.Split(delim); Credentials.SetUser(creds[0], creds[1]); isLoggedIn = true; if (LoginMode == LWLoginMode.automatic_connection) { LWInterface.NewNotification(Credentials.user_name + " logged in. Connecting...", LWInterface.Notification.LWNotificationType.Success); LWNetwork.Client.InitializeClient(); } else { LWInterface.NewNotification(Credentials.user_name + " logged in.", LWInterface.Notification.LWNotificationType.Success); } //Automatically connect after logging in if configured to do so } else { LWInterface.NewNotification("Incorrect login.", LWInterface.Notification.LWNotificationType.Error); //Do something else if the login is invalid } //If the page does not return "NLI", the login is valid //Otherwise, the incorrect credentials were provided Credentials.ClearLogin(); //Clear the user's login credentials, regardless of their validity } else { Debug.LogError("Login credentials not set, use LWLogin.Credentials.SetLogin()"); } }
/* * @author Cas * @date 2014-01-30 * @description Executes the authorization of the application with Salesforce. * Saves the instance url and token to vars of the class. * * @param username The user's salesforce.com username. * @param password The user's salesforce.com password */ public void login(string username, string password){ // check if Auth Token is already set if (token != null) return; WWWForm form = new WWWForm(); form.AddField("username", username); form.AddField("password", password); form.AddField("client_secret", clientSecret); form.AddField("client_id", clientId); form.AddField("grant_type", grantType); WWW result = new WWW(oAuthEndpoint, form); StartCoroutine(setToken(result)); }
private IEnumerator SaveFloat(string serverAddress,string key, float value){ WWWForm newForm = new WWWForm (); newForm.AddField ("key", key); newForm.AddField ("value", value.ToString()); WWW w = new WWW (serverAddress + "/saveFloat.php", newForm); while (!w.isDone) { yield return new WaitForEndOfFrame(); } if (w.error != null) { Debug.LogError (w.error); } }
public void UpdateWWWForm(ref WWWForm data) { if (fieldType == eFieldType.Verify) return; data.AddField(serverfield, value); }
public IEnumerator SendCoroutine() { AddDefaultParameters(); WWWForm requestForm = new WWWForm (); requestForm.AddField ("name", this.eventName); requestForm.AddField ("data", this.data.ToString ()); if (!this.customData.IsNull) { requestForm.AddField ("customData", this.customData.Print(false)); } else { requestForm.AddField ("customData", "{}"); } requestForm.AddField ("ts", "1470057439857"); requestForm.AddField ("queued", 0); requestForm.AddField ("debugMode", "true"); WWW request = new WWW ("https://apptracker.spilgames.com/v1/native-events/event/android/" + Spil.BundleIdEditor + "/" + this.eventName, requestForm); yield return request; // while (!request.isDone); if (request.error != null) { Debug.LogError ("Error getting data: " + request.error); Debug.LogError ("Error getting data: " + request.text); } else { JSONObject serverResponse = new JSONObject (request.text); Debug.Log ("Data returned: " + serverResponse.ToString()); ResponseEvent.Build(serverResponse); } }
/// <summary>Converts this form data to a unity form.</summary> /// <returns>A Unity WWWForm suitable for web posting.</returns> public WWWForm ToUnityForm(){ WWWForm result=new WWWForm(); if(RawFields!=null){ foreach(KeyValuePair<string,string> kvp in RawFields){ result.AddField(kvp.Key,kvp.Value); } } return result; }
public WWW POST(string url, Dictionary<string,string> post) { WWWForm form = new WWWForm(); foreach(KeyValuePair<String,String> post_arg in post) { form.AddField(post_arg.Key, post_arg.Value); } WWW www = new WWW(url, form); StartCoroutine(WaitForRequest(www)); return www; }
//Capture debug.log output, send logs to Loggly public void HandleLog(string logString, string stackTrace, LogType type) { if ((type.Equals (LogType.Log) || type.Equals(LogType.Warning)) && !ENABLE_DEBUG_LOGS) { return; } //Initialize WWWForm and store log level as a string level = type.ToString (); var loggingForm = new WWWForm(); //Add log message to WWWForm loggingForm.AddField("LEVEL", level); loggingForm.AddField("Message", logString); loggingForm.AddField("Stack_Trace", stackTrace); //Add any User, Game, or Device MetaData that would be useful to finding issues later loggingForm.AddField("Device_Model", SystemInfo.deviceModel); //Send WWW Form to Loggly, replace TOKEN with your unique ID from Loggly var sendLog = new WWW("http://logs-01.loggly.com/inputs/" + LogglyCredential.TOKEN + "/tag/Unity3D/", loggingForm); }
/// <summary> /// Tos the form. /// </summary> /// <returns>The form.</returns> public WWWForm ToForm() { WWWForm form = new WWWForm(); Type t = GetType(); FieldInfo[] fis = t.GetFields(BindingFlags.Public | BindingFlags.Instance); foreach (FieldInfo f in fis) { object val = f.GetValue(this); form.AddField(f.Name, val != null ? val.ToString() : ""); } return form; }
/** * Posts the feedback */ public void Submit() { WWWForm formData = new WWWForm(); if(this.title != null) { formData.AddField("title", this.title.text); } if(this.body != null) { formData.AddField("body", this.body.text); } if(this.pickedRating > -1) { formData.AddField("rating", this.pickedRating.ToString()); } StartCoroutine(WebService.PostForm(this.Uri, formData, OnReceiveResponse)); this.SetActiveStep(this.loadingStep); }
private IEnumerator DeleteEntry(string serverAddress,string key){ WWWForm newForm = new WWWForm (); newForm.AddField ("key", key); WWW w = new WWW (serverAddress + "/deleteEntry.php", newForm); while (!w.isDone) { yield return new WaitForEndOfFrame(); } if (w.error != null) { Debug.LogError (w.error); } }
private IEnumerator LoadFloat(string serverAddress,string key){ WWWForm newForm = new WWWForm (); newForm.AddField ("key", key); WWW w = new WWW (serverAddress + "/getFloat.php", newForm); while (!w.isDone) { yield return new WaitForEndOfFrame(); } if (w.error != null) { Debug.LogError (w.error); } store.Value = System.Convert.ToSingle(w.text); }
static public int AddField(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); if (matchType(l, argc, 2, typeof(string), typeof(int))) { UnityEngine.WWWForm self = (UnityEngine.WWWForm)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); self.AddField(a1, a2); pushValue(l, true); return(1); } else if (matchType(l, argc, 2, typeof(string), typeof(string))) { UnityEngine.WWWForm self = (UnityEngine.WWWForm)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); self.AddField(a1, a2); pushValue(l, true); return(1); } else if (argc == 4) { UnityEngine.WWWForm self = (UnityEngine.WWWForm)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); System.Text.Encoding a3; checkType(l, 4, out a3); self.AddField(a1, a2, a3); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function to call"); return(2); } catch (Exception e) { return(error(l, e)); } }
private IEnumerator LoadVector3(string serverAddress,string key){ WWWForm newForm = new WWWForm (); newForm.AddField ("key", key); WWW w = new WWW (serverAddress + "/getVector.php", newForm); while (!w.isDone) { yield return new WaitForEndOfFrame(); } if (w.error != null) { Debug.LogError (w.error); } string[] split = w.text.Split (','); store.Value = new Vector3(System.Convert.ToSingle(split[0].Trim()),System.Convert.ToSingle(split[1].Trim()),System.Convert.ToSingle(split[2].Trim())); }
float restartTimer; // Timer to count up to restarting the level #endregion Fields #region Methods public void Gameover() { // If the player has run out of health... string username = Player.username; string auth = username + ":" + Player.password; WWWForm scoreForm = new WWWForm (); scoreForm.AddField ("score", Spawn.killCount + 100000000); var headers = scoreForm.headers; headers ["Authorization"] = "Basic " + System.Convert.ToBase64String (System.Text.Encoding.ASCII.GetBytes (auth)); WWW w = new WWW ("http://localhost:3000/api/v1/scores/" + username, scoreForm.data, headers); while (!w.isDone) { }; Debug.Log ("Submiting score for " + Player.username + " with pass " + Player.password); Application.LoadLevel ("StartMenu"); //anim.SetTrigger ("GameOver"); restart = true; }
private IEnumerator TakeScreenshot() { yield return new WaitForEndOfFrame(); var width = Screen.width; var height = Screen.height; var tex = new Texture2D(width, height, TextureFormat.RGB24, false); // Read screen contents into the texture tex.ReadPixels(new Rect(0, 0, width, height), 0, 0); tex.Apply(); byte[] screenshot = tex.EncodeToPNG(); var wwwForm = new WWWForm(); wwwForm.AddBinaryData("image", screenshot, "InteractiveConsole.png"); wwwForm.AddField("message", "herp derp. I did a thing! Did I do this right?"); FB.API("me/photos", HttpMethod.POST, handleResult, wwwForm); }
//基本認証 IEnumerator BasicAuthenticate() { var form = new WWWForm(); form.AddField("name", "value"); var headers = form.headers; var rawData = form.data; var url = "http://localhost:8080/Cradle/"; //入力をBase64へシリアライズ headers["Authorization"] = "Basic " + System.Convert.ToBase64String( System.Text.Encoding.ASCII.GetBytes(GetId() + ":" + GetPass())); //テスト中のため、ログを表示 Debug.Log (GetId() + ":" + GetPass()); var www = new WWW(url, rawData, headers); yield return www; // 成功 if (www.error == null) { Debug.Log("Get Success"); SetProxyFlg(); //サーバーからJson形式のファイルを受け取る var json = www.text; // GetResponseクラスにレスポンスを格納する GetResponse response = JsonMapper.ToObject<GetResponse> (json); Debug.Log("itemid :" + response.itemId); Debug.Log("itemname" + response.itemName); Debug.Log("itemType" + response.itemType); Debug.Log("price" + response.price); Debug.Log("attack" + response.attack); Debug.Log("defence" + response.defence); Debug.Log("description" + response.description); Debug.Log("updateTime" + response.updateTime); } // 失敗 else{ Debug.Log("Get Failure : " + www.error); //サーバ^との連動が完全になるまで仮処理 SetProxyFlg(); } }
public static void AddDonation(Backer backer, Fundable fundable, string amount, string feedback, Action action) { WWWForm form = new WWWForm(); form.AddField("firstname", backer.FirstName); form.AddField("lastname", backer.FamilyName); form.AddField("mail", backer.Mail); form.AddField("fundableID", fundable.Id); form.AddField("amount", amount); form.AddField("feedback", feedback); UnityWebRequest request = UnityWebRequest.Post(endpoint + "unityDonation", form); coroutineHelper.StartCoroutine(UploadDonation(request, action)); }
static public int AddField(IntPtr l) { try{ if (matchType(l, 2, typeof(string), typeof(string))) { UnityEngine.WWWForm self = (UnityEngine.WWWForm)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); self.AddField(a1, a2); return(0); } else if (matchType(l, 2, typeof(string), typeof(string), typeof(System.Text.Encoding))) { UnityEngine.WWWForm self = (UnityEngine.WWWForm)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); System.Text.Encoding a3; checkType(l, 4, out a3); self.AddField(a1, a2, a3); return(0); } else if (matchType(l, 2, typeof(string), typeof(int))) { UnityEngine.WWWForm self = (UnityEngine.WWWForm)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); self.AddField(a1, a2); return(0); } LuaDLL.luaL_error(l, "No matched override function to call"); return(0); } catch (Exception e) { LuaDLL.luaL_error(l, e.ToString()); return(0); } }
static int AddField(IntPtr L) { try { int count = LuaDLL.lua_gettop(L); if (count == 3 && TypeChecker.CheckTypes <int>(L, 3)) { UnityEngine.WWWForm obj = (UnityEngine.WWWForm)ToLua.CheckObject <UnityEngine.WWWForm>(L, 1); string arg0 = ToLua.CheckString(L, 2); int arg1 = (int)LuaDLL.lua_tonumber(L, 3); obj.AddField(arg0, arg1); return(0); } else if (count == 3 && TypeChecker.CheckTypes <string>(L, 3)) { UnityEngine.WWWForm obj = (UnityEngine.WWWForm)ToLua.CheckObject <UnityEngine.WWWForm>(L, 1); string arg0 = ToLua.CheckString(L, 2); string arg1 = ToLua.ToString(L, 3); obj.AddField(arg0, arg1); return(0); } else if (count == 4) { UnityEngine.WWWForm obj = (UnityEngine.WWWForm)ToLua.CheckObject <UnityEngine.WWWForm>(L, 1); string arg0 = ToLua.CheckString(L, 2); string arg1 = ToLua.CheckString(L, 3); System.Text.Encoding arg2 = (System.Text.Encoding)ToLua.CheckObject <System.Text.Encoding>(L, 4); obj.AddField(arg0, arg1, arg2); return(0); } else { return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.WWWForm.AddField")); } } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
static int QPYX_AddField_YXQP(IntPtr L_YXQP) { try { int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP); if (QPYX_count_YXQP == 3 && TypeChecker.CheckTypes <int>(L_YXQP, 3)) { UnityEngine.WWWForm QPYX_obj_YXQP = (UnityEngine.WWWForm)ToLua.CheckObject <UnityEngine.WWWForm>(L_YXQP, 1); string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 2); int QPYX_arg1_YXQP = (int)LuaDLL.lua_tonumber(L_YXQP, 3); QPYX_obj_YXQP.AddField(QPYX_arg0_YXQP, QPYX_arg1_YXQP); return(0); } else if (QPYX_count_YXQP == 3 && TypeChecker.CheckTypes <string>(L_YXQP, 3)) { UnityEngine.WWWForm QPYX_obj_YXQP = (UnityEngine.WWWForm)ToLua.CheckObject <UnityEngine.WWWForm>(L_YXQP, 1); string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 2); string QPYX_arg1_YXQP = ToLua.ToString(L_YXQP, 3); QPYX_obj_YXQP.AddField(QPYX_arg0_YXQP, QPYX_arg1_YXQP); return(0); } else if (QPYX_count_YXQP == 4) { UnityEngine.WWWForm QPYX_obj_YXQP = (UnityEngine.WWWForm)ToLua.CheckObject <UnityEngine.WWWForm>(L_YXQP, 1); string QPYX_arg0_YXQP = ToLua.CheckString(L_YXQP, 2); string QPYX_arg1_YXQP = ToLua.CheckString(L_YXQP, 3); System.Text.Encoding QPYX_arg2_YXQP = (System.Text.Encoding)ToLua.CheckObject <System.Text.Encoding>(L_YXQP, 4); QPYX_obj_YXQP.AddField(QPYX_arg0_YXQP, QPYX_arg1_YXQP, QPYX_arg2_YXQP); return(0); } else { return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.WWWForm.AddField")); } } catch (Exception e_YXQP) { return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP)); } }
static public int AddField(IntPtr l) { try { #if DEBUG var method = System.Reflection.MethodBase.GetCurrentMethod(); string methodName = GetMethodName(method); #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.BeginSample(methodName); #else Profiler.BeginSample(methodName); #endif #endif int argc = LuaDLL.lua_gettop(l); if (matchType(l, argc, 2, typeof(string), typeof(int))) { UnityEngine.WWWForm self = (UnityEngine.WWWForm)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.Int32 a2; checkType(l, 3, out a2); self.AddField(a1, a2); pushValue(l, true); return(1); } else if (matchType(l, argc, 2, typeof(string), typeof(string))) { UnityEngine.WWWForm self = (UnityEngine.WWWForm)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); self.AddField(a1, a2); pushValue(l, true); return(1); } else if (argc == 4) { UnityEngine.WWWForm self = (UnityEngine.WWWForm)checkSelf(l); System.String a1; checkType(l, 2, out a1); System.String a2; checkType(l, 3, out a2); System.Text.Encoding a3; checkType(l, 4, out a3); self.AddField(a1, a2, a3); pushValue(l, true); return(1); } pushValue(l, false); LuaDLL.lua_pushstring(l, "No matched override function AddField to call"); return(2); } catch (Exception e) { return(error(l, e)); } #if DEBUG finally { #if UNITY_5_5_OR_NEWER UnityEngine.Profiling.Profiler.EndSample(); #else Profiler.EndSample(); #endif } #endif }
//After getting callback request token public IEnumerator GetTokens() { string strResponse; var frm = new UnityEngine.WWWForm(); frm.AddField("code", AuthCode); frm.AddField("client_id", CLIENT_ID); frm.AddField("client_secret", CLIENT_SECRET); frm.AddField("grant_type", "authorization_code"); frm.AddField("redirect_uri", ServerURI); // frm.headers.Add("Content-Type", "application/x-www-form-urlencoded"); using (UnityWebRequest www = UnityWebRequest.Post(String.Format(TOKEN_URI_TEMPLATE, BASE_URI), frm)) { www.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded"); yield return(www.SendWebRequest()); strResponse = www.downloadHandler.text; } /* * AddLogEntry("Sending request for tokens..."); * * WebRequest wrRequest = WebRequest.Create(String.Format(TOKEN_URI_TEMPLATE, BASE_URI)); * wrRequest.Method = "POST"; * wrRequest.ContentType = "application/x-www-form-urlencoded"; * * StreamWriter swPost = new StreamWriter(wrRequest.GetRequestStream()); * swPost.Write(FormAuthReq); * swPost.Flush(); * swPost.Close(); * * AddLogEntry("Request sent...waiting for response..."); * * WebResponse wrResponse = wrRequest.GetResponse(); * * AddLogEntry("Processing response..."); * StreamReader srResponse = new StreamReader(wrResponse.GetResponseStream()); * strResponse = srResponse.ReadToEnd(); * srResponse.Close(); */ using (TextReader sr = new StringReader(strResponse)) { using (var reader = new Newtonsoft.Json.JsonTextReader(sr)) { var ser = Newtonsoft.Json.JsonSerializer.Create(); var jtrResponse = ser.Deserialize <JSONTokenResponse>(reader); AccessToken = jtrResponse.access_token; RefreshToken = jtrResponse.refresh_token; } } ApiClient.Instance.AccessToken = AccessToken; ApiClient.Instance.RefreshToken = RefreshToken; }
/** * Authenticated resource which returns the current balance of the player in Bitcoins */ public void Balance(string name, string pass, Action<JSONObject> success, Action<string> error) { WWWForm form = new WWWForm(); form.AddField("name", name); form.AddField("pass", Util.Encrypt(pass)); t.Get("player/balance", form, success, error); }
/** * Authenticated resource which returns the current balance of the developer in Bitcoins */ public void Balance(string email, string pass, Action<JSONObject> success, Action<string> error) { WWWForm form = new WWWForm(); form.AddField("email", email); form.AddField("pass", Util.Encrypt(pass)); t.Get("developer/balance", form, success, error); }