public void Post(string handler, string bodyData, MFP_Callbacks.MFPResponseCallback res, MFP_Callbacks.MFPResponseCallback fail) { string apiUrl = MFP_API.i ().mfURL + handler; string responseJson = ""; Dictionary<string, string> headers = new Dictionary<string, string>(); headers.Add("Content-Type", "application/json"); headers.Add("Accept", "application/json"); headers.Add("X-API-KEY", MFP_API.i ().APIKey); byte[] pData = Encoding.ASCII.GetBytes(bodyData.ToCharArray()); WWW www = new WWW(apiUrl, pData, headers); while(!www.isDone){ Debug.Log(www.progress); } if(www.error != null && www.error.Length > 0) { Debug.Log("There was an error getting the file - " + www.error); } else { Debug.Log(www.text); } Debug.Log("Post Response = " + responseJson); }
public void loginUser(MFP_User user, MFP_Callbacks.MFPResponseCallback successResponse, MFP_Callbacks.MFPResponseCallback failResponse) { /* mf_API_URL/players { "username":"******", "authToken":[ { "provider":"email", "email":"*****@*****.**", "password":"******" } ] } */ //ArrayList tokenLists = new ArrayList (); Dictionary<string, object> tokens = new Dictionary<string, object>(); tokens.Add("provider", "email"); tokens.Add("email", user.email); tokens.Add("password", user.pass); //tokenLists.Add (tokens); //Dictionary<string, object> bodyParams = new Dictionary<string, object>(); //bodyParams.Add("username", user.userName); //bodyParams.Add("authTokens", tokenLists); string bodyData = JsonMapper.ToJson (tokens); HTTPRequest httpRequest = HTTPRequest.requestWithURL(MFP_API.i ().mfURL); httpRequest.Post("authenticationTokens", bodyData, successResponse, failResponse); }
public void loginUser(string email, string pass, MFP_Callbacks.MFPResponseCallback successResponse, MFP_Callbacks.MFPResponseCallback errorResponse) { mf_user = new MFP_User().loginUser(email, pass); mf_authentication.loginUser(mf_user, successResponse, errorResponse); }
public void createAccount(string userName, string email, string pass, MFP_Callbacks.MFPResponseCallback successResponse, MFP_Callbacks.MFPResponseCallback errorResponse) { mf_user = new MFP_User().createUser(userName, email, pass); mf_authentication.createAccount(mf_user, successResponse, errorResponse); }